[whatwg] Serialization of expandos on String / Boolean / Number objects

Tab Atkins Jr. jackalmage at gmail.com
Thu Aug 23 12:34:03 PDT 2012


On Thu, Aug 23, 2012 at 12:13 PM, Dumez, Christophe
<christophe.dumez at intel.com> wrote:
> Hi,
>
> The latest specification of the structured clone algorithm [1] does
> not indicate that we are supposed to serialize expandos on objects
> such as String, Boolean or Number.
>
> For example:
> var str = new String("test");
> str.foo = 3;
> window.postMessage(str, "*");
>
> Isn't str.foo property supposed to be serialized? If I read the
> specification correctly, it is not:
> """
> If input is a String object
>
>          Let output be a newly constructed String object with the same
> value as input.
> """
>
> Is this behavior really intended? I think it would make sense to
> serialize the properties attached to such objects.
>
> [1] http://www.whatwg.org/specs/web-apps/current-work/#safe-passing-of-structured-data

As far as I can tell, the Structured Clone algorithm has mostly
bottomed out into JSON, so the loss of expandos on those builtins is
intentional - keeping them would mean serializing them as objects,
rather than as literals.

~TJ



More information about the whatwg mailing list