Skip to content
Permalink
Browse files

Fix unit tests in firefox 4 and opera 11, passing null or undefined t…

…o indexOf was throwing an error in those browsers
  • Loading branch information...
timmywil
timmywil committed Apr 11, 2011
1 parent 6591f6d commit eb857e2b714e6786078cf8641941f267a6e19fa0
Showing with 6 additions and 1 deletion.
  1. +6 −1 src/traversing.js
@@ -298,13 +298,18 @@ jQuery.extend({

// Implement the identical functionality for filter and not
function winnow( elements, qualifier, keep ) {

// Can't pass null or undefined to indexOf in Firefox 4
// Set to 0 to skip string check
qualifier = qualifier || 0;

if ( jQuery.isFunction( qualifier ) ) {
return jQuery.grep(elements, function( elem, i ) {
var retVal = !!qualifier.call( elem, i, elem );
return retVal === keep;
});

} else if ( qualifier && qualifier.nodeType ) {
} else if ( qualifier.nodeType ) {
return jQuery.grep(elements, function( elem, i ) {
return (elem === qualifier) === keep;
});

0 comments on commit eb857e2

Please sign in to comment.
You can’t perform that action at this time.