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
4ac2fdda
Commit
4ac2fdda
authored
May 03, 2011
by
timmywil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix setting value attributes on option elements. Fixes #9071.
parent
6d2fd57f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
attributes.js
src/attributes.js
+1
-1
attributes.js
test/unit/attributes.js
+3
-1
No files found.
src/attributes.js
View file @
4ac2fdda
...
@@ -199,7 +199,7 @@ jQuery.fn.extend({
...
@@ -199,7 +199,7 @@ jQuery.fn.extend({
hooks
=
jQuery
.
valHooks
[
this
.
nodeName
.
toLowerCase
()
]
||
jQuery
.
valHooks
[
this
.
type
];
hooks
=
jQuery
.
valHooks
[
this
.
nodeName
.
toLowerCase
()
]
||
jQuery
.
valHooks
[
this
.
type
];
// If set returns undefined, fall back to normal setting
// If set returns undefined, fall back to normal setting
if
(
!
hooks
||
(
"set"
in
hooks
&&
hooks
.
set
(
this
,
val
,
"value"
)
===
undefined
)
)
{
if
(
!
hooks
||
!
(
"set"
in
hooks
)
||
hooks
.
set
(
this
,
val
,
"value"
)
===
undefined
)
{
this
.
value
=
val
;
this
.
value
=
val
;
}
}
});
});
...
...
test/unit/attributes.js
View file @
4ac2fdda
...
@@ -447,7 +447,7 @@ test("removeProp(String)", function() {
...
@@ -447,7 +447,7 @@ test("removeProp(String)", function() {
});
});
test
(
"val()"
,
function
()
{
test
(
"val()"
,
function
()
{
expect
(
2
5
);
expect
(
2
6
);
document
.
getElementById
(
"text1"
).
value
=
"bla"
;
document
.
getElementById
(
"text1"
).
value
=
"bla"
;
equals
(
jQuery
(
"#text1"
).
val
(),
"bla"
,
"Check for modified value of input element"
);
equals
(
jQuery
(
"#text1"
).
val
(),
"bla"
,
"Check for modified value of input element"
);
...
@@ -513,6 +513,8 @@ test("val()", function() {
...
@@ -513,6 +513,8 @@ test("val()", function() {
var
$button
=
jQuery
(
"<button value='foobar'>text</button>"
).
insertAfter
(
"#button"
);
var
$button
=
jQuery
(
"<button value='foobar'>text</button>"
).
insertAfter
(
"#button"
);
equals
(
$button
.
val
(),
"foobar"
,
"Value retrieval on a button does not return innerHTML"
);
equals
(
$button
.
val
(),
"foobar"
,
"Value retrieval on a button does not return innerHTML"
);
equals
(
$button
.
val
(
"baz"
).
html
(),
"text"
,
"Setting the value does not change innerHTML"
);
equals
(
$button
.
val
(
"baz"
).
html
(),
"text"
,
"Setting the value does not change innerHTML"
);
equals
(
jQuery
(
"<option/>"
).
val
(
"test"
).
attr
(
"value"
),
"test"
,
"Setting value sets the value attribute"
);
});
});
var
testVal
=
function
(
valueObj
)
{
var
testVal
=
function
(
valueObj
)
{
...
...
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