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
9ec429cf
Commit
9ec429cf
authored
Mar 06, 2014
by
John Hoven
Committed by
Dave Methvin
Mar 20, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Attributes: Trim whitespace from option text when returned as a value
Fixes #14858 Ref #14686 Closes gh-1531
parent
5a1db91b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
1 deletion
+17
-1
AUTHORS.txt
AUTHORS.txt
+1
-0
val.js
src/attributes/val.js
+3
-1
attributes.js
test/unit/attributes.js
+13
-0
No files found.
AUTHORS.txt
View file @
9ec429cf
...
@@ -210,4 +210,5 @@ S. Andrew Sheppard <andrew@wq.io>
...
@@ -210,4 +210,5 @@ S. Andrew Sheppard <andrew@wq.io>
Roman Reiß <me@silverwind.io>
Roman Reiß <me@silverwind.io>
Benjy Cui <benjytrys@gmail.com>
Benjy Cui <benjytrys@gmail.com>
Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>
Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>
John Hoven <hovenj@gmail.com>
src/attributes/val.js
View file @
9ec429cf
...
@@ -74,7 +74,9 @@ jQuery.extend({
...
@@ -74,7 +74,9 @@ jQuery.extend({
var
val
=
jQuery
.
find
.
attr
(
elem
,
"value"
);
var
val
=
jQuery
.
find
.
attr
(
elem
,
"value"
);
return
val
!=
null
?
return
val
!=
null
?
val
:
val
:
jQuery
.
text
(
elem
);
// Support: IE10-11+
// option.text throws exceptions (#14686, #14858)
jQuery
.
trim
(
jQuery
.
text
(
elem
)
);
}
}
},
},
select
:
{
select
:
{
...
...
test/unit/attributes.js
View file @
9ec429cf
...
@@ -1462,3 +1462,16 @@ test( "should not throw at $(option).val() (#14686)", 1, function() {
...
@@ -1462,3 +1462,16 @@ test( "should not throw at $(option).val() (#14686)", 1, function() {
ok
(
false
);
ok
(
false
);
}
}
});
});
test
(
"Insignificant white space returned for $(option).val() (#14858)"
,
function
()
{
expect
(
3
);
var
val
=
jQuery
(
"<option></option>"
).
val
();
equal
(
val
.
length
,
0
,
"Empty option should have no value"
);
val
=
jQuery
(
"<option> </option>"
).
val
();
equal
(
val
.
length
,
0
,
"insignificant white-space returned for value"
);
val
=
jQuery
(
"<option> test </option>"
).
val
();
equal
(
val
.
length
,
4
,
"insignificant white-space returned for value"
);
});
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