mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Attributes: return empty array for select-multiple with no values
Fixes gh-2562 Close gh-2689
This commit is contained in:
parent
e05c63e17a
commit
79fc806e85
@ -90,7 +90,7 @@ jQuery.extend( {
|
||||
var value, option,
|
||||
options = elem.options,
|
||||
index = elem.selectedIndex,
|
||||
one = elem.type === "select-one" || index < 0,
|
||||
one = elem.type === "select-one",
|
||||
values = one ? null : [],
|
||||
max = one ? index + 1 : options.length,
|
||||
i = index < 0 ?
|
||||
|
@ -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.equal( jQuery( select6 ).val(), null, "Non-matching set (single value) on select-multiple" );
|
||||
assert.deepEqual( jQuery( select6 ).val(), [], "Non-matching set (single value) on select-multiple" );
|
||||
|
||||
jQuery( select6 ).val( [ "nothing1", "nothing2" ] );
|
||||
assert.equal( jQuery( select6 ).val(), null, "Non-matching set (array of values) on select-multiple" );
|
||||
assert.deepEqual( jQuery( select6 ).val(), [], "Non-matching set (array of values) on select-multiple" );
|
||||
|
||||
select6.remove();
|
||||
} );
|
||||
|
Loading…
Reference in New Issue
Block a user