Skip to main content

Bug Tracker

Side navigation

#5704 closed bug (fixed)

Opened December 23, 2009 06:00AM UTC

Closed October 25, 2010 09:45PM UTC

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:

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 (0.9 KB) - added by kbwood December 23, 2009 06:01AM UTC.

    $.extend correction

Change History (2)

Changed December 23, 2009 10:59PM UTC by kbwood comment:1

component: unfilledcore
summary: Deep extend fails to copy arrayDeep extend converts array to object

Changed October 25, 2010 09:45PM UTC by rwaldron comment:2

resolution: → fixed
status: newclosed

This issue no longer exists