From 9fd56078df0bba653ea87153d6378f469842e006 Mon Sep 17 00:00:00 2001 From: Oleg Gaidarenko Date: Wed, 11 Nov 2015 18:49:04 +0300 Subject: [PATCH] Revert "Attributes: return empty array for select-multiple with no values" This reverts commit 79fc806e8500372a2278795c068d039ee287535f. --- src/attributes/val.js | 2 +- test/unit/attributes.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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(); } ); -- 2.39.5