mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Traversing: .not/.filter consistency with non-elements
Fixes gh-2808 Close gh-2809
This commit is contained in:
parent
b0b280cd61
commit
0e2f8f9eff
@ -33,7 +33,7 @@ function winnow( elements, qualifier, not ) {
|
||||
}
|
||||
|
||||
return jQuery.grep( elements, function( elem ) {
|
||||
return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
|
||||
return ( indexOf.call( qualifier, elem ) > -1 ) !== not && elem.nodeType === 1;
|
||||
} );
|
||||
}
|
||||
|
||||
|
@ -430,6 +430,17 @@ QUnit.test( "not(jQuery)", function( assert ) {
|
||||
assert.deepEqual( jQuery( "p" ).not( jQuery( "#ap, #sndp, .result" ) ).get(), q( "firstp", "en", "sap", "first" ), "not(jQuery)" );
|
||||
} );
|
||||
|
||||
QUnit.test( "not(Selector) excludes non-element nodes (gh-2808)", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var mixedContents = jQuery( "#nonnodes" ).contents(),
|
||||
childElements = q( "nonnodesElement" );
|
||||
|
||||
assert.deepEqual( mixedContents.not( "*" ).get(), [], "not *" );
|
||||
assert.deepEqual( mixedContents.not( "[id=a],[id=b]" ).get(), childElements, "not [id=a],[id=b]" );
|
||||
assert.deepEqual( mixedContents.not( "[id=a],*,[id=b]" ).get(), [], "not [id=a],*,[id=b]" );
|
||||
} );
|
||||
|
||||
QUnit.test( "has(Element)", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
var obj, detached, multipleParent;
|
||||
|
Loading…
Reference in New Issue
Block a user