Skip to main content

Bug Tracker

Side navigation

#9837 closed enhancement (cantfix)

Opened July 15, 2011 03:36PM UTC

Closed September 28, 2011 06:21PM UTC

Issue on extend (deep) with methods-properties

Reported by: tim.sebastian@gmail.com Owned by: rwaldron
Priority: low Milestone: 1.next
Component: core Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:
Description

A Deep Copy on an Object should run over Function(-Objects), too.

Right now the it behaves like this:

http://jsfiddle.net/2ptQe/

If changing the Line 365 of Version 1.6.2 from this:

if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ){

to this:

if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) || jQuery.isFunction(copy) ) ) {

it behaves more as expected:

http://jsfiddle.net/GWtgU/

Attachments (0)
Change History (6)

Changed July 15, 2011 03:38PM UTC by anonymous comment:1

sorry i forgot to state out, it concerns the "$.extend" function

Changed July 15, 2011 05:02PM UTC by rwaldron comment:2

component: unfiledcore
owner: → rwaldron
priority: undecidedlow
status: newassigned

Changed July 15, 2011 05:03PM UTC by rwaldron comment:3

Changed July 15, 2011 05:07PM UTC by rwaldron comment:4

The patch suggested above breaks the Core module of the test suite.

Changed July 16, 2011 07:43AM UTC by tim.sebastian@gmail.com comment:5

Sorry, didnt check that. It seems almost impossible, since you cant(at least i cant) isolate a function from its properties, thus it will always be passed as a reference. Creating a closure would make it all too messy, and broke the test when trying to apply the properties again (ran into an endless loop on the jQuery.sub() test)

Changed September 28, 2011 06:21PM UTC by dmethvin comment:6

resolution: → cantfix
status: assignedclosed

I agree this is nigh-on impossible to do in a generic way on arbitrary objects. Basically $.extend() works fine for our use cases inside jQuery, using plain objects and primitive values. Some of the new ES5 features would help here, so maybe in another decade we can revisit. :)