#2456 closed defect (worksforme)
[testcase] dojo.clone mangles object methods during clone
Reported by: | guest | Owned by: | James Burke |
---|---|---|---|
Priority: | high | Milestone: | 1.4 |
Component: | Core | Version: | 1.0 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description (last modified by )
Steps to reproduce:
o = {} [object Object] >>> o.f = function () {dojo.debug("SSS");} function () {...} >>> o2 = dojo.lang.shallowCopy(o, true) [object Object] >>> o.f() SSSdojo.js (line 237) >>> o2.f() >>> o2 = dojo.lang.shallowCopy(o, false) [object Object] >>> o2.f() SSS
Dojo 0.4.1 on Firefox 2.0/Ubuntu Linux 6.10
My contact info: apa3a at yahoo dot com
Attachments (3)
Change History (17)
comment:1 Changed 15 years ago by
Milestone: | → 1.1 |
---|
comment:2 Changed 14 years ago by
comment:3 Changed 14 years ago by
Owner: | changed from anonymous to alex |
---|---|
Priority: | high → normal |
severity: | major → normal |
Summary: | dojo.lang.shallowCopy mangles object methods during deep copy → [testcase] dojo.clone mangles object methods during clone |
Version: | 0.4.1 → 1.0 |
The testcase provided by peller is still an issue.
comment:4 Changed 14 years ago by
Milestone: | 1.1 → 1.2 |
---|
Move all milestone 1.1 tickets to 1.2, except for reopened tickets and tickets opened after 1.1RC1 was released.
Changed 14 years ago by
Attachment: | dojo._base.lang.clone added |
---|
Changed 14 years ago by
Attachment: | dojo.tests._base.lang added |
---|
Changed 14 years ago by
Attachment: | util.doh.runner added |
---|
comment:5 Changed 14 years ago by
what ive done
i have 3 patches maybe solving the problem
- dojo._base.lang.clone: i added a part to clone functions (was missing before)
- dojo.tests._base.lang: i outcommented the error throwing part (with the function)
- util.doh.runner: i implemented a funcEq function (which is very simple and surely not enough.. but i dont know better now) and adjusted the assertEqual method
what should probably be done next
- testing the stuff by an experienced person (knowing all the js func secrets i dont know)
- maybe adding the funcEq to the other asserts
comment:6 Changed 14 years ago by
Milestone: | 1.2 → 1.3 |
---|
as per today's meeting, punting these core bugs
comment:7 Changed 14 years ago by
Description: | modified (diff) |
---|---|
Milestone: | 1.3 → future |
comment:8 Changed 14 years ago by
Owner: | changed from alex to James Burke |
---|
comment:9 follow-up: 10 Changed 14 years ago by
Again, if you look at the description, it is the ticket for 0.4.1. Are we fixing those? Proposal: close as wontfix.
comment:10 Changed 14 years ago by
comment:11 Changed 14 years ago by
OK, I missed the test in 1.0, sorry. But just FYI: there is no way to clone a function in JavaScript. There is a hack that works in some browsers, but it is not supported in the language.
The hack:
var f = eval("(" + old.toString() + ")");
In general dojo.clone() was meant to be used only for value-based objects. I don't recall now why it clones DOM nodes too, but it is a problem that bites users time to time.
comment:12 Changed 13 years ago by
I have the same problem cloning something simple like
var test = { fu: function () { //do something }, bar:"something" };
The function fu doesn't work anymore in the cloned object.
Why not just return the function in dojo.clone()?
if(dojo.isFunction(o)) return o;
comment:13 Changed 13 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
I believe it was fixed in the course of other tickets. Please reopen if you still have problems.
Still a problem in 1.x