diff --git a/src/attributes/val.js b/src/attributes/val.js index d9dd836cb..6adf8e2d2 100644 --- a/src/attributes/val.js +++ b/src/attributes/val.js @@ -72,12 +72,9 @@ 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) - jQuery.trim( jQuery.text( elem ) ); + // Support: IE<11 + // option.value not trimmed (#14858) + return jQuery.trim( elem.value ); } }, select: { diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 55bdfffbd..1e9c2fee2 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -1459,6 +1459,11 @@ test( "should not throw at $(option).val() (#14686)", 1, function() { } }); +test( "option value not trimmed when setting via parent select", function() { + expect( 1 ); + equal( jQuery( "" ).val( "2" ).val(), "2" ); +}); + test( "Insignificant white space returned for $(option).val() (#14858)", function() { expect ( 3 );