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
425d17de
Commit
425d17de
authored
Sep 21, 2012
by
Richard Gibson
Committed by
Dave Methvin
Oct 04, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #12583: Don't ignore disabled property of select-one, close gh-932.
parent
da3ff3af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
20 deletions
+20
-20
attributes.js
src/attributes.js
+13
-19
attributes.js
test/unit/attributes.js
+7
-1
No files found.
src/attributes.js
View file @
425d17de
...
@@ -225,26 +225,25 @@ jQuery.extend({
...
@@ -225,26 +225,25 @@ jQuery.extend({
},
},
select
:
{
select
:
{
get
:
function
(
elem
)
{
get
:
function
(
elem
)
{
var
value
,
i
,
max
,
option
,
var
value
,
option
,
index
=
elem
.
selectedIndex
,
values
=
[],
options
=
elem
.
options
,
options
=
elem
.
options
,
one
=
elem
.
type
===
"select-one"
;
index
=
elem
.
selectedIndex
,
one
=
elem
.
type
===
"select-one"
||
index
<
0
,
// Nothing was selected
values
=
one
?
null
:
[],
if
(
index
<
0
)
{
max
=
one
?
index
+
1
:
options
.
length
,
return
null
;
i
=
index
<
0
?
}
max
:
one
?
index
:
0
;
// Loop through all the selected options
// Loop through all the selected options
i
=
one
?
index
:
0
;
max
=
one
?
index
+
1
:
options
.
length
;
for
(
;
i
<
max
;
i
++
)
{
for
(
;
i
<
max
;
i
++
)
{
option
=
options
[
i
];
option
=
options
[
i
];
// Don't return options that are disabled or in a disabled optgroup
// oldIE doesn't update selected after form reset (#2551)
if
(
option
.
selected
&&
(
jQuery
.
support
.
optDisabled
?
!
option
.
disabled
:
option
.
getAttribute
(
"disabled"
)
===
null
)
&&
if
(
(
option
.
selected
||
i
===
index
)
&&
(
!
option
.
parentNode
.
disabled
||
!
jQuery
.
nodeName
(
option
.
parentNode
,
"optgroup"
))
)
{
// Don't return options that are disabled or in a disabled optgroup
(
jQuery
.
support
.
optDisabled
?
!
option
.
disabled
:
option
.
getAttribute
(
"disabled"
)
===
null
)
&&
(
!
option
.
parentNode
.
disabled
||
!
jQuery
.
nodeName
(
option
.
parentNode
,
"optgroup"
)
)
)
{
// Get the specific value for the option
// Get the specific value for the option
value
=
jQuery
(
option
).
val
();
value
=
jQuery
(
option
).
val
();
...
@@ -259,11 +258,6 @@ jQuery.extend({
...
@@ -259,11 +258,6 @@ jQuery.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 @
425d17de
...
@@ -718,7 +718,7 @@ test("removeProp(String)", function() {
...
@@ -718,7 +718,7 @@ test("removeProp(String)", function() {
});
});
test
(
"val()"
,
function
()
{
test
(
"val()"
,
function
()
{
expect
(
2
0
+
(
jQuery
.
fn
.
serialize
?
6
:
0
)
);
expect
(
2
1
+
(
jQuery
.
fn
.
serialize
?
6
:
0
)
);
document
.
getElementById
(
"text1"
).
value
=
"bla"
;
document
.
getElementById
(
"text1"
).
value
=
"bla"
;
equal
(
jQuery
(
"#text1"
).
val
(),
"bla"
,
"Check for modified value of input element"
);
equal
(
jQuery
(
"#text1"
).
val
(),
"bla"
,
"Check for modified value of input element"
);
...
@@ -761,6 +761,12 @@ test("val()", function() {
...
@@ -761,6 +761,12 @@ test("val()", function() {
jQuery
(
"#select5"
).
val
(
3
);
jQuery
(
"#select5"
).
val
(
3
);
equal
(
jQuery
(
"#select5"
).
val
(),
"3"
,
"Check value on ambiguous select."
);
equal
(
jQuery
(
"#select5"
).
val
(),
"3"
,
"Check value on ambiguous select."
);
strictEqual
(
jQuery
(
"<select name='select12584' id='select12584'><option value='1' disabled='disabled'>1</option></select>"
).
val
(),
null
,
"Select-one with only option disabled (#12584)"
);
if
(
jQuery
.
fn
.
serialize
)
{
if
(
jQuery
.
fn
.
serialize
)
{
var
checks
=
jQuery
(
"<input type='checkbox' name='test' value='1'/><input type='checkbox' name='test' value='2'/><input type='checkbox' name='test' value=''/><input type='checkbox' name='test'/>"
).
appendTo
(
"#form"
);
var
checks
=
jQuery
(
"<input type='checkbox' name='test' value='1'/><input type='checkbox' name='test' value='2'/><input type='checkbox' name='test' value=''/><input type='checkbox' name='test'/>"
).
appendTo
(
"#form"
);
...
...
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