Commit 88572ee6 authored by John Resig's avatar John Resig

Make sure that the correct args are passed in to the filter callback (and by...

Make sure that the correct args are passed in to the filter callback (and by extension, the not callback). Fixes #5594.
parent a5f8a144
...@@ -8,7 +8,7 @@ var runtil = /Until$/, ...@@ -8,7 +8,7 @@ var runtil = /Until$/,
var winnow = function( elements, qualifier, keep ) { var winnow = function( elements, qualifier, keep ) {
if ( jQuery.isFunction( qualifier ) ) { if ( jQuery.isFunction( qualifier ) ) {
return jQuery.grep(elements, function(elem, i) { return jQuery.grep(elements, function(elem, i) {
return !!qualifier.call( elem, i ) === keep; return !!qualifier.call( elem, i, elem ) === keep;
}); });
} else if ( qualifier.nodeType ) { } else if ( qualifier.nodeType ) {
......
...@@ -64,9 +64,11 @@ test("filter(Selector)", function() { ...@@ -64,9 +64,11 @@ test("filter(Selector)", function() {
}); });
test("filter(Function)", 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() { 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() { test("filter(Element)", function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment