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:
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:
Attachments (0)
Change History (6)
Changed July 15, 2011 03:38PM UTC by comment:1
Changed July 15, 2011 05:02PM UTC by comment:2
component: | unfiled → core |
---|---|
owner: | → rwaldron |
priority: | undecided → low |
status: | new → assigned |
Changed July 15, 2011 05:03PM UTC by comment:3
Confirmed. http://jsfiddle.net/rwaldron/NJuHF/
Changed July 15, 2011 05:07PM UTC by comment:4
The patch suggested above breaks the Core module of the test suite.
Changed July 16, 2011 07:43AM UTC by 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 comment:6
resolution: | → cantfix |
---|---|
status: | assigned → closed |
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. :)
sorry i forgot to state out, it concerns the "$.extend" function