Bug Tracker

Opened 13 years ago

Closed 12 years ago

#6675 closed bug (fixed)

makeArray fails on objects with a length property

Reported by: 314159abcde Owned by:
Priority: undecided Milestone: 1.4.3
Component: core Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:



jQuery.makeArray( {'length':5} );

in the firebug console on any jQuery site and it will output [undefined, undefined, undefined, undefined, undefined]

when it should return [Object { length=5}]

This is causing issues where I have an object with a length and width attribute, since it will not pass through makeArray properly.

Change History (3)

comment:1 Changed 12 years ago by Kiyoto

What is the expected behavior here? I changed line 650-652 of src/core.js to

else {

if ( type === "object" ) {

for ( var k in array ) {

push.call( ret, array[k] );


} else {

jQuery.merge( ret, array );


This will get the desired behavior for your case, but it breaks a slew of jQuery test cases. I was wondering what the expected behavior for jQuery.makeArray({'length':3}) was.

comment:2 Changed 12 years ago by Kiyoto

Never mind. I misread your post. Please scratch the previous comment

comment:3 Changed 12 years ago by addyosmani

Priority: undecided
Resolution: fixed
Status: newclosed

As Kiyoto has already applied a patch for this to achieve the desired effect, I am updating this ticket to fixed. Please re-submit/re-open if required.

Note: See TracTickets for help on using tickets.