Filter: Use direct filter in winnow

for both simple and complex selectors

Fixes gh-3272
Closes gh-3910
This commit is contained in:
Saptak Sengupta 2018-01-10 11:04:31 +05:30 committed by Timmy Willison
parent 625e19cd9b
commit 4765bb5c78
No known key found for this signature in database
GPG Key ID: 5F0C8B73EF56CE6F

View File

@ -8,8 +8,6 @@ define( [
"use strict"; "use strict";
var risSimple = /^.[^:#\[\.,]*$/;
// Implement the identical functionality for filter and not // Implement the identical functionality for filter and not
function winnow( elements, qualifier, not ) { function winnow( elements, qualifier, not ) {
if ( isFunction( qualifier ) ) { if ( isFunction( qualifier ) ) {
@ -32,16 +30,8 @@ function winnow( elements, qualifier, not ) {
} ); } );
} }
// Simple selector that can be filtered directly, removing non-Elements // Filtered directly for both simple and complex selectors
if ( risSimple.test( qualifier ) ) {
return jQuery.filter( qualifier, elements, not ); return jQuery.filter( qualifier, elements, not );
}
// Complex selector, compare the two sets, removing non-Elements
qualifier = jQuery.filter( qualifier, elements );
return jQuery.grep( elements, function( elem ) {
return ( indexOf.call( qualifier, elem ) > -1 ) !== not && elem.nodeType === 1;
} );
} }
jQuery.filter = function( expr, elems, not ) { jQuery.filter = function( expr, elems, not ) {