This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
See bug 10877 (http://www.w3.org/Bugs/Public/show_bug.cgi?id=10877) The current algorithm converts DAGs into trees, which isn't the most appropriate "clone" of object data. The algorithm should be modified to clone DAGs correctly (e.g. Modifying the algorithm to re-use "memory" instead of copying into "new memory" or to assign "new memory" back to "memory" as the recursion unwinds). If the purpose of the algorithm is not support DAGs then it should throw just as it does for cyclic graphs.
The original intent was to make the algorithm essentially do the same as one would get if one converted the object to JSON and back. That has somewhat changed with the addition of various features over time, though, so maybe we should indeed revisit this. I would appreciate feedback from other implementors who have implemented this algorithm to see whether this is something that would quickly result in interoperable implementations, or whether this is something that would linger on with diverging implementations for some time. In other words: If I change this, will Opera, Gecko, and WebKit change to match?
I don't think that this will cause any problems to Gecko. Structured cloning is used very rarely so far, and I strongly suspect that most of the time people use very simple objects that won't be affected by this change. In fact, most of the time we use JSON behind the scenes, and so far no one has noticed the difference. This is changing though, so we will be using a custom structured-clone implementation soon. The only requirement we have is that a structured-clone-able object can be serialized and serialized both quickly and with little overhead. This is needed for example in IndexedDB where we need to serialize the object to be able to store it in the database for later retrieval. Similarly we need to serialize and parse the object when passing data to workers.
I should also say that we're currently in the middle of rewriting our structured clone implementation. So any feedback on what the algorithm is going to be very soon would greatly helpful.
This would be no problem for us. I am told we take extra steps to not implement this at the moment.
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document: http://dev.w3.org/html5/decision-policy/decision-policy.html Status: Accepted Change Description: see diff given below Rationale: I made the algorithm support cycles and repeated objects in graphs.
Checked in as WHATWG revision r5587. Check-in comment: Make the structured clone algorithm support cycles. http://html5.org/tools/web-apps-tracker?from=5586&to=5587