From 3c7f2af81d877b24a5e5b6488e78621fcf96b265 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Mon, 10 Dec 2012 20:19:26 -0500 Subject: [PATCH] Be specific about Firefox nodes-as-nodelist. Never assume that modern browsers will "get it right". Signed-off-by: Rick Waldron --- src/core.js | 4 ++++ test/unit/core.js | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) 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(){ -- 2.39.5