Permalink
Browse files

Filter: Use direct filter in winnow

for both simple and complex selectors

Fixes gh-3272
Closes gh-3910
  • Loading branch information...
SaptakS authored and timmywil committed Jan 10, 2018
1 parent 625e19c commit 4765bb5c7840fc5f725f5bda38afcebc3730fbfc
Showing with 2 additions and 12 deletions.
  1. +2 −12 src/traversing/findFilter.js
@@ -8,8 +8,6 @@ define( [
"use strict";
var risSimple = /^.[^:#\[\.,]*$/;
// Implement the identical functionality for filter and not
function winnow( elements, qualifier, not ) {
if ( isFunction( qualifier ) ) {
@@ -32,16 +30,8 @@ function winnow( elements, qualifier, not ) {
} );
}
// Simple selector that can be filtered directly, removing non-Elements
if ( risSimple.test( qualifier ) ) {
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;
} );
// Filtered directly for both simple and complex selectors
return jQuery.filter( qualifier, elements, not );
}
jQuery.filter = function( expr, elems, not ) {

0 comments on commit 4765bb5

Please sign in to comment.