Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Attributes: Trim whitespace from option text when returned as a value
Fixes #14858 Ref #14686 Closes gh-1531 (cherry picked from commit 9ec429c) Conflicts: src/attributes/val.js
- Loading branch information
Showing
3 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -71,6 +71,16 @@ jQuery.fn.extend({ | ||
|
||
jQuery.extend({ | ||
valHooks: { | ||
option: { | ||
get: function( elem ) { | ||
var val = jQuery.find.attr( elem, "value" ); | ||
return val != null ? | ||
val : | ||
// Support: IE10-11+ | ||
// option.text throws exceptions (#14686, #14858) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dmethvin
Member
|
||
jQuery.trim( jQuery.text( elem ) ); | ||
} | ||
}, | ||
select: { | ||
get: function( elem ) { | ||
var value, option, | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Instead of this could you check
element.firstChild ? element.text : ''
that would avoid the poisoned property and the extra calls fortrim
/text
. Maybe closer to the original.