Skip to content
Permalink
Browse files

Merge pull request #465 from anton-ryzhov/master

Fixes #10076. $.inArray crashes IE6 and Chrome if second argument is `null` or `undefined` (Thanks anton-ryzhov!)
  • Loading branch information...
dmethvin committed Aug 25, 2011
2 parents f4811bf + 190136c commit a839af034db2bd934e4d4fa6758a3fed8de74174
Showing with 13 additions and 0 deletions.
  1. +3 −0 src/core.js
  2. +10 −0 test/unit/core.js
@@ -679,6 +679,9 @@ jQuery.extend({
},

inArray: function( elem, array ) {
if ( !array ) {
return -1;
}

if ( indexOf ) {
return indexOf.call( array, elem );
@@ -934,6 +934,16 @@ test("jQuery.makeArray", function(){
same( jQuery.makeArray({length: "5"}), [], "Make sure object is coerced properly.");
});

test("jQuery.inArray", function(){
expect(3);

equals( jQuery.inArray( 0, false ), -1 , "Search in 'false' as array returns -1 and doesn't throw exception" );

equals( jQuery.inArray( 0, null ), -1 , "Search in 'null' as array returns -1 and doesn't throw exception" );

equals( jQuery.inArray( 0, undefined ), -1 , "Search in 'undefined' as array returns -1 and doesn't throw exception" );
});

test("jQuery.isEmptyObject", function(){
expect(2);

0 comments on commit a839af0

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