-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
structuredClone
#984
structuredClone
#984
Conversation
There is a nice test suite for this algorithm in web-platform-tests, but I'm unsure the license is compatible. |
Yes, I wrote above how to do it.
The same as with
|
You could copy those tests and add a copyright note to those tests files. |
I think that for this case switch (classof(value)) {
case 'Boolean': ...
case 'BigInt': ...
case 'Number': ...
case 'String': ...
case 'Date': ...
case 'RegExp': ...
case 'Map': ...
} |
4b3b21e
to
73b5186
Compare
1bfdd07
to
422802c
Compare
…omMark and transfer
Co-authored-by: Kenta Moriuchi <moriken@kimamass.com>
native `structuredClone` is already available in unstable versions of all modern engines, but no one of them still not passes new (related to html/5749) errors cloning tests
…non-serializable instead of `DOMException`
a016d1e
to
e0d475e
Compare
Published. |
Fixes #969
This is my naive approach to implement the structured cloning algorithm. It doesn't actually serialize and deserialize as the specification suggests, but it will give the closest clone I can replicate.
Clones
NB: https://gist.github.com/petamoriken/3802602b8e93d89e5b4c21e36683cadb#gistcomment-3899514
Concerns
Could we get rid of WeakMap dependency?ShouldstructuredClone
polyfill ES6 Map and Set for the environments that don't have them?All ofinstanceof
calls should've been internal slot checks.Error.prototype.stack
wildly varies between JS engines, and probably we should clone them too. Some notes can be found here.Blob, File and other web APIs are platform objects and their cloning behavior is defined by their IDL? Not very sure we should include this as well.