w3c/css-houdini-drafts

[css-typed-om] structuredClone for typed-om objects

DevSDK opened this issue · 0 comments

DevSDK commented

"structuredClone can’t deal with CSSUnitValue objects" issue is filed on crbug [1].

Currently, the css-typed-om spec[2] does not mark the [Serializable] attribute for typed-om objects.
Consequently, these objects are not contained in the platform objects that can be serializable according to the HTML spec [3].

So the browsers comply with that spec that throws an exception.
However, the following codes look very natural:

Given this, browsers appropriately throw an exception to comply with the spec.
However, consider the following code:

structuredClone(CSS.px(2))

This looks quite intuitive and straightforward.

If there is no extra context that I missed, could we consider supporting it?

[1] https://bugs.chromium.org/p/chromium/issues/detail?id=1444708&q=is%3Astarred&can=2
[2] https://www.w3.org/TR/css-typed-om-1/#cssunitvalue
[3] https://html.spec.whatwg.org/multipage/structured-data.html#serializable-objects