Be specific about Firefox nodes-as-nodelist. Never assume that modern browsers will "get it right".

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
This commit is contained in:
Rick Waldron 2012-12-10 20:19:26 -05:00
parent 07a7b3e4cf
commit 3c7f2af81d
2 changed files with 7 additions and 1 deletions

View File

@ -919,6 +919,10 @@ function isArraylike( obj ) {
return false;
}
if ( obj.nodeType === 1 && length ) {
return true;
}
return type === "array" || type !== "function" &&
( length === 0 ||
typeof length === "number" && length > 0 && ( length - 1 ) in obj );

View File

@ -1141,7 +1141,9 @@ test("jQuery.makeArray", function(){
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(){