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
a467aa0a
Commit
a467aa0a
authored
Nov 13, 2011
by
Oleg
Committed by
Dave Methvin
Nov 14, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #10773. Improve parameter handling in removeAttr.
parent
fa96f4bd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
25 deletions
+38
-25
attributes.js
src/attributes.js
+3
-3
attributes.js
test/unit/attributes.js
+35
-22
No files found.
src/attributes.js
View file @
a467aa0a
...
@@ -355,12 +355,12 @@ jQuery.extend({
...
@@ -355,12 +355,12 @@ jQuery.extend({
var
propName
,
attrNames
,
name
,
l
,
var
propName
,
attrNames
,
name
,
l
,
i
=
0
;
i
=
0
;
if
(
elem
.
nodeType
===
1
)
{
if
(
value
&&
typeof
value
===
"string"
&&
elem
.
nodeType
===
1
)
{
attrNames
=
(
value
||
""
).
split
(
rspace
);
attrNames
=
jQuery
.
trim
(
value
).
toLowerCase
().
split
(
" "
);
l
=
attrNames
.
length
;
l
=
attrNames
.
length
;
for
(
;
i
<
l
;
i
++
)
{
for
(
;
i
<
l
;
i
++
)
{
name
=
attrNames
[
i
]
.
toLowerCase
()
;
name
=
attrNames
[
i
];
propName
=
jQuery
.
propFix
[
name
]
||
name
;
propName
=
jQuery
.
propFix
[
name
]
||
name
;
// See #9699 for explanation of this approach (setting first, then removal)
// See #9699 for explanation of this approach (setting first, then removal)
...
...
test/unit/attributes.js
View file @
a467aa0a
...
@@ -481,6 +481,41 @@ test("removeAttr(String)", function() {
...
@@ -481,6 +481,41 @@ test("removeAttr(String)", function() {
}
}
});
});
test
(
"removeAttr, #"
,
function
()
{
var
div
=
jQuery
(
"<div />"
);
ok
(
div
.
removeAttr
(
""
),
"empty string"
);
ok
(
div
.
removeAttr
(),
"nothing"
);
ok
(
div
.
removeAttr
(
false
),
"false"
);
ok
(
div
.
removeAttr
(
true
),
"true"
);
ok
(
div
.
removeAttr
({
}),
"object"
);
ok
(
div
.
removeAttr
(
function
(){}
),
"function"
);
});
test
(
"removeAttr(Multi String)"
,
function
()
{
expect
(
8
);
var
div
=
jQuery
(
"<div id='a' alt='b' title='c' rel='d'></div>"
),
tests
=
{
id
:
"a"
,
alt
:
"b"
,
title
:
"c"
,
rel
:
"d"
};
jQuery
.
each
(
tests
,
function
(
key
,
val
)
{
equal
(
div
.
attr
(
key
),
val
,
"Attribute `"
+
key
+
"` exists, and has a value of `"
+
val
+
"`"
);
});
div
.
removeAttr
(
"id alt title rel "
);
jQuery
.
each
(
tests
,
function
(
key
,
val
)
{
equal
(
div
.
attr
(
key
),
undefined
,
"Attribute `"
+
key
+
"` was removed"
);
});
});
test
(
"prop(String, Object)"
,
function
()
{
test
(
"prop(String, Object)"
,
function
()
{
expect
(
31
);
expect
(
31
);
...
@@ -548,28 +583,6 @@ test("prop(String, Object)", function() {
...
@@ -548,28 +583,6 @@ test("prop(String, Object)", function() {
equal
(
$form
.
prop
(
"enctype"
),
"multipart/form-data"
,
"Set the enctype of a form (encoding in IE6/7 #6743)"
);
equal
(
$form
.
prop
(
"enctype"
),
"multipart/form-data"
,
"Set the enctype of a form (encoding in IE6/7 #6743)"
);
});
});
test
(
"removeAttr(Multi String)"
,
function
()
{
expect
(
8
);
var
div
=
jQuery
(
"<div id='a' alt='b' title='c' rel='d'></div>"
),
tests
=
{
id
:
"a"
,
alt
:
"b"
,
title
:
"c"
,
rel
:
"d"
};
jQuery
.
each
(
tests
,
function
(
key
,
val
)
{
equal
(
div
.
attr
(
key
),
val
,
"Attribute `"
+
key
+
"` exists, and has a value of `"
+
val
+
"`"
);
});
div
.
removeAttr
(
"id alt title rel"
);
jQuery
.
each
(
tests
,
function
(
key
,
val
)
{
equal
(
div
.
attr
(
key
),
undefined
,
"Attribute `"
+
key
+
"` was removed"
);
});
});
test
(
"prop('tabindex')"
,
function
()
{
test
(
"prop('tabindex')"
,
function
()
{
expect
(
8
);
expect
(
8
);
...
...
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