]> source.dussan.org Git - jquery.git/commitdiff
Revert "Attributes: return empty array for select-multiple with no values"
authorOleg Gaidarenko <markelog@gmail.com>
Wed, 11 Nov 2015 15:49:04 +0000 (18:49 +0300)
committerOleg Gaidarenko <markelog@gmail.com>
Wed, 11 Nov 2015 15:49:04 +0000 (18:49 +0300)
This reverts commit 79fc806e8500372a2278795c068d039ee287535f.

src/attributes/val.js
test/unit/attributes.js

index 5f0b73e008bac2ae6c6e31b230a8662f8f78ac6b..caf0126d4cfaa08a0b47e157b3b3b648cd483684 100644 (file)
@@ -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 ?
index 9bf2876881c7f9a25423c338254f12c549ad554e..9ea29a105356522492968cb54ee955c5dfe59388 100644 (file)
@@ -903,10 +903,10 @@ QUnit.test( "val() with non-matching values on dropdown list", function( assert
 
        var select6 = jQuery( "<select multiple id=\"select6\"><option value=\"1\">A</option><option value=\"2\">B</option></select>" ).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();
 } );