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
43a41ba7
Commit
43a41ba7
authored
Feb 10, 2011
by
rwldrn
Committed by
Anton M
Feb 10, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure .val() works after form.reset() in IE. Fixes #2551.
parent
78fc79fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
attributes.js
src/attributes.js
+5
-0
attributes.js
test/unit/attributes.js
+19
-0
No files found.
src/attributes.js
View file @
43a41ba7
...
@@ -198,6 +198,11 @@ jQuery.fn.extend({
...
@@ -198,6 +198,11 @@ jQuery.fn.extend({
}
}
}
}
// Fixes Bug #2551 -- select.val() broken in IE after form.reset()
if
(
one
&&
!
values
.
length
&&
options
.
length
)
{
return
jQuery
(
options
[
index
]
).
val
();
}
return
values
;
return
values
;
}
}
...
...
test/unit/attributes.js
View file @
43a41ba7
...
@@ -546,6 +546,25 @@ test("val(Function) with incoming value", function() {
...
@@ -546,6 +546,25 @@ test("val(Function) with incoming value", function() {
equals
(
jQuery
(
"#select1"
).
val
(),
"4"
,
"Should be possible to set the val() to a newly created option"
);
equals
(
jQuery
(
"#select1"
).
val
(),
"4"
,
"Should be possible to set the val() to a newly created option"
);
});
});
// testing if a form.reset() breaks a subsequent call to a select element's .val() (in IE only)
test
(
"val(select) after form.reset() (Bug #2551)"
,
function
()
{
expect
(
3
);
jQuery
(
'<form id="kk" name="kk"><select id="kkk"><option value="cf">cf</option><option value="gf">gf</option></select></form>'
).
appendTo
(
"#main"
);
jQuery
(
"#kkk"
).
val
(
"gf"
);
document
.
kk
.
reset
();
equal
(
jQuery
(
"#kkk"
)[
0
].
value
,
"cf"
,
"Check value of select after form reset."
);
equal
(
jQuery
(
"#kkk"
).
val
(),
"cf"
,
"Check value of select after form reset."
);
// re-verify the multi-select is not broken (after form.reset) by our fix for single-select
same
(
jQuery
(
'#select3'
).
val
(),
[
'1'
,
'2'
],
'Call val() on a multiple="multiple" select'
);
jQuery
(
"#kk"
).
remove
();
});
var
testAddClass
=
function
(
valueObj
)
{
var
testAddClass
=
function
(
valueObj
)
{
expect
(
5
);
expect
(
5
);
var
div
=
jQuery
(
"div"
);
var
div
=
jQuery
(
"div"
);
...
...
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