Bug Tracker

Opened 13 years ago

Closed 12 years ago

#5704 closed bug (fixed)

Deep extend converts array to object

Reported by: kbwood Owned by:
Priority: major Milestone: 1.4
Component: core Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:

Description

If an object already has an attribute that is not an array/object and is deep extended to make that attribute an array, it converts the array into an object. For example:

var x = {y: 1}; $.extend(true, x, {y: [2, 3]}); alert(x.y); x.y = {0: 2, 1: 3}

To fix, check that the source is already an array/object before trying to use when recursively extending. See line 18 in the attached code extract.

Attachments (1)

extendcorrection.txt (877 bytes) - added by kbwood 13 years ago.
$.extend correction

Download all attachments as: .zip

Change History (3)

Changed 13 years ago by kbwood

Attachment: extendcorrection.txt added

$.extend correction

comment:1 Changed 13 years ago by kbwood

Component: unfilledcore
Summary: Deep extend fails to copy arrayDeep extend converts array to object

comment:2 Changed 12 years ago by Rick Waldron

Resolution: fixed
Status: newclosed

This issue no longer exists

http://jsfiddle.net/rwaldron/Q5kJR/2/

Note: See TracTickets for help on using tickets.