Support RawJSONObject in structuredClone
Categories
(Core :: JavaScript Engine, task, P3)
Tracking
()
People
(Reporter: bthrall, Unassigned)
References
(Blocks 1 open bug)
Details
Currently, trying to structuredClone a RawJSONObject
results in 'DataCloneError: RawJSON object could not be cloned'.
This is correct, as I read the structuredClone spec.
Should we fix this? As far as I know, there's no technical reason we couldn't clone a RawJSONObject
.
Comment 1•3 months ago
|
||
(In reply to Bryan Thrall [:bthrall] from comment #0)
Currently, trying to structuredClone a
RawJSONObject
results in 'DataCloneError: RawJSON object could not be cloned'.This is correct, as I read the structuredClone spec.
Yes, as I read the spec: these are not platform objects (they aren't defined in WebIDL, they don't implement an interface), which means cloneability defers to the StructuredSerialize operation. With a literal reading of the spec, step 22 of https://html.spec.whatwg.org/multipage/structured-data.html#structuredserializeinternal will fail because of the existence of an [[IsRawJSON]]
internal slot.
(But with a literal reading, step 22 will fail for... well, everything: the JS spec says "All objects have an internal slot named [[PrivateElements]],...". Oops! I think this is mostly just an artifact of structured clone straddling between whatwg and tc39.)
Should we fix this? As far as I know, there's no technical reason we couldn't clone a
RawJSONObject
.
We should probably file an issue with the proposal. I may as well just do that. Though we could probably go ahead and implement in parallel; I at least don't see any particular reason to exclude it.
Comment 2•3 months ago
|
||
Oh, wait. I don't think I know how to file an issue, because the change would currently need to go into the whatwg spec.
Comment 3•3 months ago
|
||
Ok, filed https://github.com/whatwg/html/issues/10424
I don't know anything about their process.
Comment 4•3 months ago
|
||
Filed https://github.com/whatwg/html/issues/10425 for the general issue of the specs not quite lining up, though I don't think anything can really be done about that without moving structured cloning into the JS spec. Which may happen. And will probably create mismatches at the new boundary.
Reporter | ||
Comment 5•1 month ago
|
||
Based on the response to https://github.com/whatwg/html/issues/10425 (they added mention of [[PrivateElements]]
to the spec), it seems like we are waiting on them to take action on https://github.com/whatwg/html/issues/10424.
We don't have to support structuredClone for RawJSONObject
to release the JSON.parse with source feature, so we could just wait.
Description
•