Bug Tracker

Modify

Ticket #1907 (closed bug: fixed)

Opened 6 years ago

Last modified 14 months ago

jQuery.extend() deep destroys array of zero

Reported by: genezys Owned by:
Priority: major Milestone: 1.2.2
Component: core Version: 1.2.1
Keywords: Cc:
Blocking: Blocked by:

Description

jQuery.extend(true, {plop:[]}, {plop:[0]}) 

returns an object where plop is an empty array.

Change History

comment:1 Changed 6 years ago by davidserduke

It appears this is a coersion problem. In jQuery.extend there is a section

// Prevent never-ending loop
if ( target == prop[i] )
  continue;

Coersion says that [] is false and 0 is false. So they are equal. This test should probably use === instead.

comment:2 Changed 6 years ago by davidserduke

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in [3841].

Note, the code treats all objects the same with no special handling for Arrays at this point.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.