W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2015

Re: Exposing structured clone as an API?

From: Joshua Bell <jsbell@google.com>
Date: Fri, 24 Apr 2015 15:13:10 -0700
Message-ID: <CAD649j7CojKRRKWCa8PEMcN+Fi-CCRNcEF0==S6iqQcRYZGbZw@mail.gmail.com>
To: Anne van Kesteren <annevk@annevk.nl>
Cc: Robin Berjon <robin@w3.org>, Ted Mielczarek <ted@mozilla.com>, public-webapps <public-webapps@w3.org>, Katelyn Gadd <kg@luminance.org>
It seems like the OP's intent is just to deep-copy an object. Something
like the OP's tweet... or this, which we use in some tests:

function structuredClone(o) {
    return new Promise(function(resolve) {
        var mc = new MessageChannel();
        mc.port2.onmessage = function(e) { resolve(e.data); };

... but synchronous, which is fine, since the implicit
serialization/deserialization needs to be synchronous anyway.

If we're not dragging in the notion of extensibility, is there
complication?  I'm pretty sure this would be about a two line function in
Blink. That said, without being able to extend it, is it really interesting
to developers?

On Fri, Apr 24, 2015 at 2:05 PM, Anne van Kesteren <annevk@annevk.nl> wrote:

> On Fri, Apr 24, 2015 at 2:08 AM, Robin Berjon <robin@w3.org> wrote:
> > Does this have to be any more complicated than adding a toClone()
> convention
> > matching the ones we already have?
> Yes, much more complicated. This does not work at all. You need
> something to serialize the object so you can transport it to another
> (isolated) global.
> --
> https://annevankesteren.nl/
Received on Friday, 24 April 2015 22:13:38 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:27:31 UTC