-
Notifications
You must be signed in to change notification settings - Fork 156
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
Support HTML serialization/structured clone #548
Comments
didn't indexeddb refuse to support bigint? temporals would be even a harder sell. |
@kaizhu256 IndexedDB supports BigInt as values. As keys, there wasn't sufficient demonstrated interest in use cases. I expect us to follow this pattern for Temporal as well: initially, support Temporal as values (through structured clone), and later possibly as keys (through special IndexedDB-specific support) if there is sufficient interest. |
For background: w3c/IndexedDB#231 |
k thx for clarification |
Stage 3 is probably best for this so that implementers are well aware that structured clone is supported when they go about implementing Temporal. This is a straightforward task. |
|
For custom tz and calendar: I suggest that we go by internal slots. If they lack the internal slot of the built-in calendar or tz, throw. If they do have the internal slot but also are a subclass with some methods overridden, ignore those changes and just serialize by the id. |
I agree with that ^ but it speaks to the need for subclasses to be able to provide an arbitrary ID, not just a built-in one, otherwise on the other side, subclasses will be of the wrong type. |
I don't see how providing an arbitrary ID would make it work... you would still need matching behavior on the other side somehow. |
That's true - so subclasses just aren't effectively serializable? |
Right. In general, functions and classes are not serializable. |
Would it be better then for serializing subclasses to throw rather than silently serializing incorrectly? |
I'm not really sure of how the details should work out. HTML has some cases where things throw and some where serialization changes a bit. I think we should look at the details and generally follow HTML conventions where possible. If we have a choice point, I agree with preferring throwing, but I consider this lower priority than following conventions. |
HTML pull request: whatwg/html#6284 |
@Ms2ger has completed a first draft of structured clone for Temporal types at whatwg/html#6284 . I think this is enough for Stage 3, but we should have multiple browser support by Stage 4. |
Closing this, in favour of whatwg/html#6284. |
@slightlyoff pointed out that Temporal objects should transparently be serialized by HTML, i.e., structured clone, i.e., "just working" round trip in
postMessage
(including in Node.js worker_threads!), IndexedDB, etc. Supporting this would be a matter of making a PR against HTML analogous to whatwg/html#3480 . I don't think custom calendars or timezones could be serializable (causing a DataCloneError), but the built-in ones should be fine to serialize. No rush to take an action to take right now; we can prepare this PR when this proposal is at (or almost at) Stage 3.The text was updated successfully, but these errors were encountered: