| 9 | |
| 10 | // Implement the identical functionality for filter and not |
| 11 | function winnow( elements, qualifier, not ) { |
| 12 | if ( jQuery.isFunction( qualifier ) ) { |
| 13 | return jQuery.grep( elements, function( elem, i ) { |
| 14 | /* jshint -W018 */ |
| 15 | return !!qualifier.call( elem, i, elem ) !== not; |
| 16 | }); |
| 17 | |
| 18 | } |
| 19 | |
| 20 | if ( qualifier.nodeType ) { |
| 21 | return jQuery.grep( elements, function( elem ) { |
| 22 | return ( elem === qualifier ) !== not; |
| 23 | }); |
| 24 | |
| 25 | } |
| 26 | |
| 27 | if ( typeof qualifier === "string" ) { |
| 28 | if ( risSimple.test( qualifier ) ) { |
| 29 | return jQuery.filter( qualifier, elements, not ); |
| 30 | } |
| 31 | |
| 32 | qualifier = jQuery.filter( qualifier, elements ); |
| 33 | } |
| 34 | |
| 35 | return jQuery.grep( elements, function( elem ) { |
| 36 | return ( indexOf.call( qualifier, elem ) >= 0 ) !== not; |
| 37 | }); |
| 38 | } |
| 39 | |
| 40 | jQuery.filter = function( expr, elems, not ) { |
| 41 | var elem = elems[ 0 ]; |