]> source.dussan.org Git - jquery.git/commitdiff
Make sure that the correct args are passed in to the filter callback (and by extensio...
authorJohn Resig <jeresig@gmail.com>
Thu, 10 Dec 2009 06:03:14 +0000 (22:03 -0800)
committerJohn Resig <jeresig@gmail.com>
Thu, 10 Dec 2009 06:03:14 +0000 (22:03 -0800)
src/traversing.js
test/unit/traversing.js

index d6947ace64400cba82b86f8c28af3a787ad53344..942138c37d470d6ff5bffa0775f20835e3ad03e9 100644 (file)
@@ -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 ) {
index a235bbd5ae306df48386ef8688d90f33e8aca596..c97de6d4dd9e1bd1bd2b4853227e4ffc2ab51c63 100644 (file)
@@ -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() {