Skip to content

Commit

Permalink
Be specific about Firefox nodes-as-nodelist. Never assume that modern…
Browse files Browse the repository at this point in the history
… browsers will "get it right".

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed Dec 11, 2012
1 parent 07a7b3e commit 3c7f2af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/core.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -919,6 +919,10 @@ function isArraylike( obj ) {
return false; return false;
} }


if ( obj.nodeType === 1 && length ) {
return true;
}

return type === "array" || type !== "function" && return type === "array" || type !== "function" &&
( length === 0 || ( length === 0 ||
typeof length === "number" && length > 0 && ( length - 1 ) in obj ); typeof length === "number" && length > 0 && ( length - 1 ) in obj );
Expand Down
4 changes: 3 additions & 1 deletion test/unit/core.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1141,7 +1141,9 @@ test("jQuery.makeArray", function(){


equal( jQuery.makeArray(/a/)[0].constructor, RegExp, "Pass makeArray a regex" ); equal( jQuery.makeArray(/a/)[0].constructor, RegExp, "Pass makeArray a regex" );


ok( jQuery.makeArray(document.getElementById("form")).length >= 13, "Pass makeArray a form (treat as elements)" ); // Some nodes inherit traits of nodelists
ok( jQuery.makeArray(document.getElementById("form")).length >= 13,
"Pass makeArray a form (treat as elements)" );
}); });


test("jQuery.inArray", function(){ test("jQuery.inArray", function(){
Expand Down

0 comments on commit 3c7f2af

Please sign in to comment.