Skip to content

Commit 3c7f2af

Browse files
committedDec 11, 2012
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>
1 parent 07a7b3e commit 3c7f2af

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

‎src/core.js

+4
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,10 @@ function isArraylike( obj ) {
919919
return false;
920920
}
921921

922+
if ( obj.nodeType === 1 && length ) {
923+
return true;
924+
}
925+
922926
return type === "array" || type !== "function" &&
923927
( length === 0 ||
924928
typeof length === "number" && length > 0 && ( length - 1 ) in obj );

‎test/unit/core.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,9 @@ test("jQuery.makeArray", function(){
11411141

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

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

11471149
test("jQuery.inArray", function(){

0 commit comments

Comments
 (0)