Fix unit tests in firefox 4 and opera 11, passing null or undefined to indexOf was throwing an error in those browsers

This commit is contained in:
timmywil 2011-04-11 11:54:55 -04:00
parent 6591f6dd9d
commit eb857e2b71

View file

@ -298,13 +298,18 @@ jQuery.extend({
// Implement the identical functionality for filter and not // Implement the identical functionality for filter and not
function winnow( elements, qualifier, keep ) { 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 ) ) { if ( jQuery.isFunction( qualifier ) ) {
return jQuery.grep(elements, function( elem, i ) { return jQuery.grep(elements, function( elem, i ) {
var retVal = !!qualifier.call( elem, i, elem ); var retVal = !!qualifier.call( elem, i, elem );
return retVal === keep; return retVal === keep;
}); });
} else if ( qualifier && qualifier.nodeType ) { } else if ( qualifier.nodeType ) {
return jQuery.grep(elements, function( elem, i ) { return jQuery.grep(elements, function( elem, i ) {
return (elem === qualifier) === keep; return (elem === qualifier) === keep;
}); });