aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Waldron <waldron.rick@gmail.com>2012-12-10 20:19:26 -0500
committerRick Waldron <waldron.rick@gmail.com>2012-12-10 20:19:26 -0500
commit3c7f2af81d877b24a5e5b6488e78621fcf96b265 (patch)
tree00787f6bad86a8227dac2aaba0e3626d216ea493
parent07a7b3e4cf961e51bddcdb90cdca34f9126ed286 (diff)
downloadjquery-3c7f2af81d877b24a5e5b6488e78621fcf96b265.tar.gz
jquery-3c7f2af81d877b24a5e5b6488e78621fcf96b265.zip
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>
-rw-r--r--src/core.js4
-rw-r--r--test/unit/core.js4
2 files changed, 7 insertions, 1 deletions
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(){