mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Attributes: Trim whitespace from option text when returned as a value
Fixes #14858
Ref #14686
Closes gh-1531
(cherry picked from commit 9ec429cf62)
Conflicts:
src/attributes/val.js
This commit is contained in:
@@ -1459,3 +1459,16 @@ test( "should not throw at $(option).val() (#14686)", 1, function() {
|
||||
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" );
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user