Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
05d907d1
Commit
05d907d1
authored
Aug 28, 2013
by
Timmy Willison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for custom attr handles duck-punching the boolean attr handle
parent
2af2e74e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
attr.js
src/attributes/attr.js
+6
-4
attributes.js
test/unit/attributes.js
+14
-0
No files found.
src/attributes/attr.js
View file @
05d907d1
...
@@ -145,17 +145,19 @@ boolHook = {
...
@@ -145,17 +145,19 @@ boolHook = {
// Retrieve booleans specially
// Retrieve booleans specially
jQuery
.
each
(
jQuery
.
expr
.
match
.
bool
.
source
.
match
(
/
\w
+/g
),
function
(
i
,
name
)
{
jQuery
.
each
(
jQuery
.
expr
.
match
.
bool
.
source
.
match
(
/
\w
+/g
),
function
(
i
,
name
)
{
var
getter
=
attrHandle
[
name
]
||
jQuery
.
find
.
attr
,
var
getter
=
attrHandle
[
name
]
||
jQuery
.
find
.
attr
;
fn
=
attrHandle
[
name
]
=
getSetInput
&&
getSetAttribute
||
!
ruseDefault
.
test
(
name
)
?
attrHandle
[
name
]
=
getSetInput
&&
getSetAttribute
||
!
ruseDefault
.
test
(
name
)
?
function
(
elem
,
name
,
isXML
)
{
function
(
elem
,
name
,
isXML
)
{
var
ret
;
var
ret
,
handle
;
if
(
!
isXML
)
{
if
(
!
isXML
)
{
// Avoid an infinite loop by temporarily removing this function from the getter
// Avoid an infinite loop by temporarily removing this function from the getter
handle
=
attrHandle
[
name
];
attrHandle
[
name
]
=
ret
;
attrHandle
[
name
]
=
ret
;
ret
=
getter
(
elem
,
name
,
isXML
)
!=
null
?
ret
=
getter
(
elem
,
name
,
isXML
)
!=
null
?
name
.
toLowerCase
()
:
name
.
toLowerCase
()
:
null
;
null
;
attrHandle
[
name
]
=
fn
;
attrHandle
[
name
]
=
handle
;
}
}
return
ret
;
return
ret
;
}
:
}
:
...
...
test/unit/attributes.js
View file @
05d907d1
...
@@ -473,6 +473,20 @@ test( "attr(String, Object)", function() {
...
@@ -473,6 +473,20 @@ test( "attr(String, Object)", function() {
equal
(
jQuery
(
"#name"
).
attr
(
"nonexisting"
,
undefined
).
attr
(
"nonexisting"
),
undefined
,
".attr('attribute', undefined) does not create attribute (#5571)"
);
equal
(
jQuery
(
"#name"
).
attr
(
"nonexisting"
,
undefined
).
attr
(
"nonexisting"
),
undefined
,
".attr('attribute', undefined) does not create attribute (#5571)"
);
});
});
test
(
"attr - extending the boolean attrHandle"
,
function
()
{
expect
(
1
);
var
called
=
false
,
_handle
=
jQuery
.
expr
.
attrHandle
.
checked
||
$
.
noop
;
jQuery
.
expr
.
attrHandle
.
checked
=
function
()
{
called
=
true
;
_handle
.
apply
(
this
,
arguments
);
};
jQuery
(
"input"
).
attr
(
"checked"
);
called
=
false
;
jQuery
(
"input"
).
attr
(
"checked"
);
ok
(
called
,
"The boolean attrHandle does not drop custom attrHandles"
);
});
test
(
"attr(String, Object) - Loaded via XML document"
,
function
()
{
test
(
"attr(String, Object) - Loaded via XML document"
,
function
()
{
expect
(
2
);
expect
(
2
);
var
xml
=
createDashboardXML
(),
var
xml
=
createDashboardXML
(),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment