Opened 12 years ago
Closed 11 years ago
#9837 closed enhancement (cantfix)
Issue on extend (deep) with methods-properties
Reported by: | Owned by: | Rick Waldron | |
---|---|---|---|
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/
Change History (6)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Component: | unfiled → core |
---|---|
Owner: | set to Rick Waldron |
Priority: | undecided → low |
Status: | new → assigned |
comment:4 Changed 12 years ago by
The patch suggested above breaks the Core module of the test suite.
comment:5 Changed 12 years ago by
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)
comment:6 Changed 11 years ago by
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