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
e0900a68
Commit
e0900a68
authored
Mar 26, 2011
by
timmywil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue where non-existant attributes on forms in IE6/7 were throwing errors
parent
3892df20
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
attributes.js
src/attributes.js
+7
-5
attributes.js
test/unit/attributes.js
+5
-4
No files found.
src/attributes.js
View file @
e0900a68
...
...
@@ -311,10 +311,11 @@ jQuery.extend({
return
undefined
;
}
else
{
// Check form objects in IE (multiple bugs related)
if
(
isFormObjects
)
{
elem
.
getAttributeNode
(
name
).
nodeValue
=
value
;
// Only use nodeValue if the attribute node exists on the form
if
(
isFormObjects
&&
(
ret
=
elem
.
getAttributeNode
(
name
))
)
{
ret
.
nodeValue
=
value
;
}
else
{
elem
.
setAttribute
(
name
,
value
);
}
...
...
@@ -330,8 +331,9 @@ jQuery.extend({
// Check form objects in IE (multiple bugs related)
if
(
isFormObjects
)
{
// Return undefined for empty string, which is the blank nodeValue in IE
ret
=
elem
.
getAttributeNode
(
name
).
nodeValue
||
undefined
;
// Return undefined if not specified instead of empty string
ret
=
elem
.
getAttributeNode
(
name
);
return
ret
&&
ret
.
specified
?
ret
.
nodeValue
:
undefined
;
}
else
{
ret
=
elem
.
getAttribute
(
name
);
}
...
...
test/unit/attributes.js
View file @
e0900a68
...
...
@@ -75,7 +75,7 @@ test("prop(String, Object)", function() {
});
test
(
"attr(String)"
,
function
()
{
expect
(
2
5
);
expect
(
2
6
);
equals
(
jQuery
(
'#text1'
).
attr
(
'type'
),
"text"
,
'Check for type attribute'
);
equals
(
jQuery
(
'#radio1'
).
attr
(
'type'
),
"radio"
,
'Check for type attribute'
);
...
...
@@ -88,6 +88,7 @@ test("attr(String)", function() {
equals
(
jQuery
(
'#name'
).
attr
(
'name'
),
"name"
,
'Check for name attribute'
);
equals
(
jQuery
(
'#text1'
).
attr
(
'name'
),
"action"
,
'Check for name attribute'
);
ok
(
jQuery
(
'#form'
).
attr
(
'action'
).
indexOf
(
"formaction"
)
>=
0
,
'Check for action attribute'
);
equals
(
jQuery
(
'#form'
).
attr
(
'blah'
,
'blah'
).
attr
(
'blah'
),
'blah'
,
'Set non-existant attribute on a form'
);
// [7472] & [3113] (form contains an input with name="action" or name="id")
var
extras
=
jQuery
(
'<input name="id" name="name" /><input id="target" name="target" />'
).
appendTo
(
'#testForm'
);
...
...
@@ -214,7 +215,7 @@ test("attr(String, Object)", function() {
td
.
attr
(
"colspan"
,
"2"
);
equals
(
td
[
0
].
colSpan
,
2
,
"Check colspan is correctly set"
);
table
.
attr
(
"cellspacing"
,
"2"
);
equals
(
table
[
0
].
cellSpacing
,
2
,
"Check cellspacing is correctly set"
);
equals
(
table
[
0
].
cellSpacing
,
"2"
,
"Check cellspacing is correctly set"
);
// for #1070
jQuery
(
"#name"
).
attr
(
'someAttr'
,
'0'
);
...
...
@@ -385,9 +386,9 @@ test("attr('tabindex', value)", function() {
});
test
(
"removeAttr(String)"
,
function
()
{
expect
(
1
);
expect
(
2
);
equals
(
jQuery
(
'#mark'
).
removeAttr
(
"class"
)[
0
].
className
,
""
,
"remove class"
);
equals
(
jQuery
(
'#form'
).
removeAttr
(
'id'
).
attr
(
'id'
),
undefined
,
'Remove id'
);
});
test
(
"removeProp(String)"
,
function
()
{
...
...
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