From: John Resig Date: Thu, 10 Dec 2009 06:03:14 +0000 (-0800) Subject: Make sure that the correct args are passed in to the filter callback (and by extensio... X-Git-Url: http://git.asbjorn.biz/?p=jquery.git;a=commitdiff_plain;h=88572ee6924c2322c9d405280b493c4a894f14e2 Make sure that the correct args are passed in to the filter callback (and by extension, the not callback). Fixes #5594. --- diff --git a/src/traversing.js b/src/traversing.js index d6947ac..942138c 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -8,7 +8,7 @@ var runtil = /Until$/, var winnow = function( elements, qualifier, keep ) { if ( jQuery.isFunction( qualifier ) ) { return jQuery.grep(elements, function(elem, i) { - return !!qualifier.call( elem, i ) === keep; + return !!qualifier.call( elem, i, elem ) === keep; }); } else if ( qualifier.nodeType ) { diff --git a/test/unit/traversing.js b/test/unit/traversing.js index a235bbd..c97de6d 100644 --- a/test/unit/traversing.js +++ b/test/unit/traversing.js @@ -64,9 +64,11 @@ test("filter(Selector)", function() { }); test("filter(Function)", function() { - expect(1); + expect(2); same( jQuery("p").filter(function() { return !jQuery("a", this).length }).get(), q("sndp", "first"), "filter(Function)" ); + + same( jQuery("p").filter(function(i, elem) { return !jQuery("a", elem).length }).get(), q("sndp", "first"), "filter(Function) using arg" ); }); test("filter(Element)", function() {