[whatwg] [html5] Question on the structured cloning algorithm

On Thu, 26 May 2011, Stewart Brodie wrote:
>
> Ian Hickson <ian at hixie.ch> wrote:
> 
> > On Tue, 24 May 2011, Stewart Brodie wrote:
> > >
> > > Do getters need to be called to obtain a value which can be stored
> > > (after being cloned itself) in the result?
> > 
> > I'm not sure I follow the question. Can you elaborate?
> 
> Are getters called during cloning?  i.e. what do I get if I clone this:
> 
> { get a() { return 1 } }
> 
> Do I get { a: 1 } or do I get {}  ?

Assuming "a" is an enumerable property of the object, yes, it would be 
copied, which would involve calling the getter.

This causes some unfortunate side-effects, which will be fixed once I get 
around to fixing this bug:

   http://www.w3.org/Bugs/Public/show_bug.cgi?id=12101

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Thursday, 26 May 2011 12:30:05 UTC