Core: Fixed :filled selector for multiple select elements. closes #1661, #1662.

This commit is contained in:
KJ
2015-12-09 16:36:08 -06:00
committed by Markus Staab
parent 9962f627c0
commit bd45147a0e
2 changed files with 10 additions and 1 deletions

View File

@@ -190,7 +190,8 @@ $.extend( $.expr[ ":" ], {
// http://jqueryvalidation.org/filled-selector/
filled: function( a ) {
return !!$.trim( "" + $( a ).val() );
var val = $( a ).val();
return val !== null && !!$.trim( "" + val );
},
// http://jqueryvalidation.org/unchecked-selector/

View File

@@ -1223,6 +1223,14 @@ test( "expression: :filled", function() {
equal( $( e ).filter( ":filled" ).length, 0 );
e.value = " a ";
equal( $( e ).filter( ":filled" ).length, 1 );
e = $( "#meal" )[ 0 ];
equal( $( e ).filter( ":filled" ).length, 0 );
$( e ).val( "1" );
equal( $( e ).filter( ":filled" ).length, 1 );
e = $( "#selectf7" )[ 0 ];
equal( $( e ).filter( ":filled" ).length, 0 );
$( e ).val( [ "1", "2" ] );
equal( $( e ).filter( ":filled" ).length, 1 );
} );
test( "expression: :unchecked", function() {