| 2843 | |
| 2844 | // Implement the identical functionality for filter and not |
| 2845 | function winnow(elements, qualifier, not) { |
| 2846 | if (isFunction(qualifier)) { |
| 2847 | return jQuery.grep(elements, function (elem, i) { |
| 2848 | return !!qualifier.call(elem, i, elem) !== not; |
| 2849 | }); |
| 2850 | } |
| 2851 | |
| 2852 | // Single element |
| 2853 | if (qualifier.nodeType) { |
| 2854 | return jQuery.grep(elements, function (elem) { |
| 2855 | return (elem === qualifier) !== not; |
| 2856 | }); |
| 2857 | } |
| 2858 | |
| 2859 | // Arraylike of elements (jQuery, arguments, Array) |
| 2860 | if (typeof qualifier !== 'string') { |
| 2861 | return jQuery.grep(elements, function (elem) { |
| 2862 | return indexOf.call(qualifier, elem) > -1 !== not; |
| 2863 | }); |
| 2864 | } |
| 2865 | |
| 2866 | // Filtered directly for both simple and complex selectors |
| 2867 | return jQuery.filter(qualifier, elements, not); |
| 2868 | } |
| 2869 | |
| 2870 | jQuery.filter = function (expr, elems, not) { |
| 2871 | var elem = elems[0]; |