From: Rick Waldron Date: Tue, 11 Dec 2012 01:19:26 +0000 (-0500) Subject: Be specific about Firefox nodes-as-nodelist. Never assume that modern browsers will... X-Git-Tag: 1.9.0b1~39 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3c7f2af81d877b24a5e5b6488e78621fcf96b265;p=jquery.git Be specific about Firefox nodes-as-nodelist. Never assume that modern browsers will "get it right". Signed-off-by: Rick Waldron --- diff --git a/src/core.js b/src/core.js index 9832daa59..5db9b5e82 100644 --- a/src/core.js +++ b/src/core.js @@ -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 ); diff --git a/test/unit/core.js b/test/unit/core.js index ba68afa75..ee0fd0bb2 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -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(){