Skip to content

Temporal proposal HTML serialization support#6284

Open
littledan wants to merge 2 commits intowhatwg:mainfrom
littledan:structured-clone-temporal
Open

Temporal proposal HTML serialization support#6284
littledan wants to merge 2 commits intowhatwg:mainfrom
littledan:structured-clone-temporal

Conversation

@littledan
Copy link
Copy Markdown
Contributor

@littledan littledan commented Jan 13, 2021

This patch lets Temporal objects be serialized, both in storage and with
postMessage, if they use built-in calendars and timezones. This is the
only expected integration of Temporal with HTML/DOM expected initially;
see earlier discussion in w3ctag/design-reviews#311

The current draft just includes Temporal.PlainDate, and it will be extended
to all of the Temporal types after initial review. This patch should not be
landed until (at least) Temporal reaches Stage 3.

(See WHATWG Working Mode: Changes for more details.)


/infrastructure.html ( diff )
/structured-data.html ( diff )

Base automatically changed from master to main January 15, 2021 07:58
@littledan
Copy link
Copy Markdown
Contributor Author

The changes that @Ms2ger made to include all appropriate Temporal objects and serialize exclusively built-in things LGTM. AFAIK, these are all the changes needed to integrate Temporal into HTML.

@Ms2ger Ms2ger marked this pull request as ready for review January 29, 2021 10:16
@domenic domenic force-pushed the structured-clone-temporal branch 2 times, most recently from 81f0aae to bcfc01a Compare August 11, 2021 16:07
Copy link
Copy Markdown
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rebased this and fixed some editorial nits. It LGTM but needs implementer interest (probably we have it through the TC39 process?) and, most importantly, tests.

Copy link
Copy Markdown
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calendar user code thread seems to not yet be resolved?

@domenic domenic added the needs tests Moving the issue forward requires someone to write tests label Aug 11, 2021
Copy link
Copy Markdown
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK cool. Just waiting on tests, implementer interest, and browser bugs then before we can merge.

@Ms2ger Ms2ger force-pushed the structured-clone-temporal branch 2 times, most recently from 50b7305 to cd5e85c Compare June 20, 2024 11:45
Ms2ger added a commit to web-platform-tests/wpt that referenced this pull request Jun 21, 2024
@Ms2ger
Copy link
Copy Markdown
Member

Ms2ger commented Jun 21, 2024

I updated this to match the consensus from the 102nd TC39 Meeting (12 June), notably dropping Calendar and TimeZone objects. (These changes have not all made it into the proposal spec text yet.) I also wrote a wpt PR with some tests. I'm not sure if this needs independent implementer interest signals / implementation bugs, but if so, I'll deal with that next week.

@domenic
Copy link
Copy Markdown
Member

domenic commented Jun 24, 2024

Editorial nit: we prefer to avoid single-step <ol>s, so instead of

  1. If ...
    1. Set value ...

we'd write

  1. If ..., then set value ...

Because of the force-pushing, I can't tell if this has been there the whole time and we hadn't caught it previously (sorry if so!), or if it was introduced in recent revisions.

Anyway, normative contents still LGTM.

It would be good to have independent bugs, since structured serialization is often dealt with by different browser teams.

For implementer interest, if you have some indication that TC39 consensus includes structured serialization, then that's enough. (I'm unclear whether the consensus you're referring to in the above comment is for structured serialization, or whether it's for dropping Calendar and TimeZone objects.)

When should we merge this? I guess Temporal is stage 3, which is when we've merged things into HTML in the past. So I'm happy to merge once the checkboxes are checked, as long as you are.

@Ms2ger Ms2ger removed the needs tests Moving the issue forward requires someone to write tests label Jun 26, 2024
@Ms2ger
Copy link
Copy Markdown
Member

Ms2ger commented Jun 26, 2024

Thanks!

Editorial nit: we prefer to avoid single-step <ol>s, so instead of

  1. If ...

    1. Set value ...

we'd write

  1. If ..., then set value ...

Because of the force-pushing, I can't tell if this has been there the whole time and we hadn't caught it previously (sorry if so!), or if it was introduced in recent revisions.

The previous version had substeps to handle user-defined time zones and calendars. I'd like to maybe slightly push back against this comment, though, because I think merging the substep into the previous paragraph would be somewhat less readable due to the quite big records I'm creating. I defer to you if you do still want me to do it, though.

Anyway, normative contents still LGTM.

It would be good to have independent bugs, since structured serialization is often dealt with by different browser teams.

Filed those.

For implementer interest, if you have some indication that TC39 consensus includes structured serialization, then that's enough. (I'm unclear whether the consensus you're referring to in the above comment is for structured serialization, or whether it's for dropping Calendar and TimeZone objects.)

Sorry for the confusion - the TC39 consensus was for dropping Calendar and TimeZone objects. My understanding is that structured cloning hasn't really been discussed in TC39. I filed standards positions issues to make sure.

When should we merge this? I guess Temporal is stage 3, which is when we've merged things into HTML in the past. So I'm happy to merge once the checkboxes are checked, as long as you are.

I guess we can give a bit of time for people to respond to the standards positions, but apart from that, I'd be happy to merge.

@annevk
Copy link
Copy Markdown
Member

annevk commented Jul 5, 2024

I heard that V8 doesn't want to add this per the latest TC39 meeting? What about SpiderMonkey? JSC is somewhat neutral.

I agree that normally we'd just add Stage 3, but if implementer interest is not really there I'm less sure.

cc @syg @codehag @mgaudet

@annevk annevk changed the title [WIP] Temporal proposal HTML serialization support Temporal proposal HTML serialization support Jul 5, 2024
@mgaudet
Copy link
Copy Markdown
Contributor

mgaudet commented Jul 9, 2024

Regarding structured clone, we'll work through the Mozilla standards position to develop a real position. I can't speak for V8, but I don't think Temporal's trajectory has changed particularly.

@controversial
Copy link
Copy Markdown

I heard that V8 doesn't want to add this per the latest TC39 meeting

@annevk could you point to the spot in the tc39 meeting notes where that’s established? I couldn’t find it in a quick scan through the 2024-06 notes

@syg
Copy link
Copy Markdown
Contributor

syg commented May 8, 2025

Sorry I don't actually remember discussing serialization of Temporal objects. At this time I can't reconstruct any reasons why V8 would be against it.

@annevk
Copy link
Copy Markdown
Member

annevk commented May 9, 2025

No implementer being against it is good, but not sufficient. Is any implementer interested in doing this?

This patch lets Temporal objects be serialized, both in storage and with
postMessage, if they use built-in calendars and timezones. This is the
only expected integration of Temporal with HTML/DOM expected initially;
see earlier discussion in w3ctag/design-reviews#311

Co-authored-by: Domenic Denicola <d@domenic.me>
Co-authored-by: Ms2ger <Ms2ger@igalia.com>
@lucacasonato
Copy link
Copy Markdown
Member

Deno is interested, and we're also happy to do the V8 implementation.

@annevk
Copy link
Copy Markdown
Member

annevk commented Mar 1, 2026

This addition makes sense to WebKit as well.

jedel1043 added a commit to boa-dev/temporal that referenced this pull request Mar 1, 2026
I am working on a structured clone integration for Temporal objects in
V8
(whatwg/html#6284). This requires that reference
years
and days are exposed on PlainMonthDay and PlainYearMonth respectively
for
temporal_capi. Additionally, a numerical month getter is needed for
PlainMonthDay.

---------

Co-authored-by: José Julián Espina <jedel@startmail.com>
Ms2ger added a commit to web-platform-tests/wpt that referenced this pull request Mar 2, 2026
Copy link
Copy Markdown

@ptomato ptomato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The names of some internal slots changed a couple of years ago, and dates/times were organized into Records. As far as I can tell, here's what would be needed to update this PR accordingly.

Copy link
Copy Markdown

@ptomato ptomato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fully up to date now.

@Ms2ger Ms2ger added the agenda+ To be discussed at a triage meeting label Mar 4, 2026
@Ms2ger
Copy link
Copy Markdown
Member

Ms2ger commented Mar 4, 2026

@nicolo-ribaudo will attend

@nicolo-ribaudo
Copy link
Copy Markdown
Collaborator

nicolo-ribaudo commented Mar 5, 2026

Mozilla voiced support in the WHATNOT meeting, and they want to review this PR.

@dminor
Copy link
Copy Markdown

dminor commented Mar 5, 2026

@anba if you have time, could you have a quick look at the PR?

@anba
Copy link
Copy Markdown

anba commented Mar 7, 2026

The overall changes look reasonable to me. I just wonder if calendar and time zones should get re-validated when deserialised, in case the supported calendars or time zones changed in some way. For example when serialising to disk and later deserialising from disk with a newer browser version, it's possible that some calendars or time zones are no longer supported or are canonicalised differently (only relevant for calendar identifiers).

@annevk annevk added the i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. label Mar 7, 2026
@annevk
Copy link
Copy Markdown
Member

annevk commented Mar 7, 2026

That's a great concern. That makes me wonder whether serializing objects that contain such timezone data to disk is something we should prohibit for v1 until we know more about the landscape. We could use the forStorage infrastructure for this. Especially as these issues would only hit a small percentage of end users. cc @whatwg/i18n

@hsivonen
Copy link
Copy Markdown
Member

hsivonen commented Mar 9, 2026

I think we should not prohibit serializing values that have attached time zones, because it would be bad to give Web developers an incentive to prefer UTC offset over cities in values that get serialized. UTC offset does not accomplish the same as a city even within one year in places that have daylight saving time, and more generally, user-perceived time zones over time are attached to political rules in a particular place and not to a particular offset.

I think we should explicitly cover the possibility of time zone canonicalization changing over time (Kiev to Kyiv, Calcutta to Kolkata, etc.) and the possibility of a time zone going away. In the case of canonicalization change, we can assume there to be data that enables re-canonicalization under the new rules.

I'm not sure what we should spec about time zones going away, but it seem unlikely enough that we shouldn't prohibit serialization due to that possibility.

@annevk
Copy link
Copy Markdown
Member

annevk commented Mar 9, 2026

Fair, filed tc39/proposal-temporal#3294 to discuss this further with TC39.

@anba
Copy link
Copy Markdown

anba commented Mar 9, 2026

Possible scenarios I'm worried about:

Calendar identifiers:

  1. An existing calendar is split into different variants, for example iso8601-new and iso8601-old. The previous calendar identifier iso8601 gets canonicalised to iso8601-new. Serialised was the old identifier iso8601, what should happen on deserialisation?
  2. A calendar identifier is removed, like when we removed support for islamic and islamic-rgsa in Which Hijri calendars should Temporal support? tc39/proposal-intl-era-monthcode#29.

Even if we're 100% sure neither 1 nor 2 will ever happen for all currently supported calendars, can we assume the same for any future calendar extensions, like tc39/proposal-intl-era-monthcode#18?

Time zone identifiers:

  1. tzdata has removed old identifiers in the past (US/Pacific-New, Canada/East-Saskatchewan, SystemV/AST4ADT, etc.). It'd be good to know how to handle this, in case it happens again.
  2. ICU4C still supports these old identifiers and in addition to that also other (Java-based?) identifiers (AST, BST, CST, etc.). If a browser switches their internal implementation from ICU4C to, for example ICU4X, it's necessary to handle the case when time zone identifiers are no longer supported. (We can't assume implementations add their own validation on top of ICU to reject non-IANA time zone identifiers, see [1, 2, 3, 4].)

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1797225
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=1879554
[3] https://bugzilla.mozilla.org/show_bug.cgi?id=2007641
[4] tc39/test262#4005

@nicolo-ribaudo nicolo-ribaudo removed the agenda+ To be discussed at a triage meeting label Mar 12, 2026
@jsahleen
Copy link
Copy Markdown

This seems ok from the i18n working group perspective. The question related to calendars has more to do with the stability of calendar identifiers than it does with how they should be serialized. Same would apply to time zone identifiers, I would think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addition/proposal New features or enhancements i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. topic: serialize and transfer

Development

Successfully merging this pull request may close these issues.