W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2011

[whatwg] structured clone algorithm should be defined for primitive values

From: David Flanagan <david@davidflanagan.com>
Date: Fri, 28 Jan 2011 11:11:41 -0800
Message-ID: <4D4314ED.8040605@davidflanagan.com>

The structured clone algorithm is currently defined only for object 
inputs and doesn't say what should happen when a primitive value is 
passed to it.  (The internal structured cloning algorithm handles 
primitives, but the outer level one does not.)

Browser implementations allow primitives such as strings to be passed to 
History.pushState(), window.postMessage() and other methods that 
reference the structured clone algorithm.

I think you can fix this by changing "object" to "value" in four places:

> When a user agent is required to obtain a structured clone of an object [change this to value],
it must run the following algorithm, which either returns a separate 
object [value],
or throws an exception.
> Let input be the object [value] being cloned.
> Let memory be an association list of pairs of objects, initially empty. This is used to handle duplicate references. In each pair of objects, one is called the source object and the other the destination object.
> Let output be the object [value] resulting from calling the internal structured cloning algorithm with input and memory.


Received on Friday, 28 January 2011 11:11:41 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:03 UTC