From: Oleg Gaidarenko Date: Wed, 11 Nov 2015 15:49:04 +0000 (+0300) Subject: Revert "Attributes: return empty array for select-multiple with no values" X-Git-Tag: 2.2.0~70 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9fd56078df0bba653ea87153d6378f469842e006;p=jquery.git Revert "Attributes: return empty array for select-multiple with no values" This reverts commit 79fc806e8500372a2278795c068d039ee287535f. --- diff --git a/src/attributes/val.js b/src/attributes/val.js index 5f0b73e00..caf0126d4 100644 --- a/src/attributes/val.js +++ b/src/attributes/val.js @@ -90,7 +90,7 @@ jQuery.extend( { var value, option, options = elem.options, index = elem.selectedIndex, - one = elem.type === "select-one", + one = elem.type === "select-one" || index < 0, values = one ? null : [], max = one ? index + 1 : options.length, i = index < 0 ? diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 9bf287688..9ea29a105 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -903,10 +903,10 @@ QUnit.test( "val() with non-matching values on dropdown list", function( assert var select6 = jQuery( "" ).appendTo( "#form" ); jQuery( select6 ).val( "nothing" ); - assert.deepEqual( jQuery( select6 ).val(), [], "Non-matching set (single value) on select-multiple" ); + assert.equal( jQuery( select6 ).val(), null, "Non-matching set (single value) on select-multiple" ); jQuery( select6 ).val( [ "nothing1", "nothing2" ] ); - assert.deepEqual( jQuery( select6 ).val(), [], "Non-matching set (array of values) on select-multiple" ); + assert.equal( jQuery( select6 ).val(), null, "Non-matching set (array of values) on select-multiple" ); select6.remove(); } );