Skip to content

Commit

Permalink
[WIP] Temporal proposal HTML serialization support
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
littledan authored and domenic committed Aug 11, 2021
1 parent 2bccd29 commit 207b8bd
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2876,6 +2876,15 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<p>User agents that support JavaScript must also implement the <cite>Top-Level Await</cite>
proposal. <ref spec=JSTLA></p>

<p>User agents that support JavaScript must also implement the <cite>Temporal</cite>
proposal. The following terms are defined in the Temporal proposal and used in this
specification: <ref spec=JSTEMPORAL></p>

<ul>
<li>The <dfn data-x-href="https://tc39.es/proposal-temporal/#sec-temporal.plaindate">Temporal.PlainDate</dfn> constructor</li>
</ul>
</dd>

<p>User agents that support JavaScript must also implement the <cite>Import Assertions</cite>
proposal. The following terms are defined there, and used in this specification: <ref
spec=JSIMPORTASSERTIONS></p>
Expand Down Expand Up @@ -8422,6 +8431,21 @@ interface <dfn interface>DOMStringList</dfn> {
</ol>
</li>

<li>
<p>Otherwise, if <var>value</var> has an [[InitializedTemporalDate]] internal slot, then:</p>

<ol>
<li><p>If <var>value</var>.[[Calendar]] does not have a [[InitializedTemporalCalendar]]
internal slot, then throw a <span>"<code>DataCloneError</code>"</span>
<code>DOMException</code>.</p></li>

<li><p>Set <var>serialized</var> to { [[Type]]: "Temporal.PlainDate", [[ISOYear]]:
<var>value</var>.[[ISOYear]], [[ISOMonth]]: <var>value</var>.[[ISOMonth]], [[ISODay]]:
<var>value</var>.[[ISODay]], [[Calendar]]: <var>value</var>.[[Calendar]].[[Identifier]]
}.</p></li>
</ol>
</li>

<li>
<p>Otherwise, if <var>value</var> is a <span>platform object</span> that is a <span
data-x="serializable objects">serializable object</span>:</p>
Expand Down Expand Up @@ -8831,6 +8855,17 @@ o.myself = o;</code></pre>
</ol>
</li>

<li>
<p>Otherwise, if <var>serialized</var>.[[Type]] is "Temporal.PlainDate", then:</p>

<ol>
<li><p>Set <var>value</var> to ! <span>Construct</span>(<span
data-x="Temporal.PlainDate">%Temporal.PlainDate%</span>, &laquo;
<var>serialized</var>.[[ISOYear]], <var>serialized</var>.[[ISOMonth]],
<var>serialized</var>.[[ISODay]], &raquo;).</p></li>
</ol>
</li>

<li>
<p>Otherwise:</p>

Expand Down Expand Up @@ -125485,6 +125520,9 @@ INSERT INTERFACES HERE
<dt id="refsJSTLA">[JSTLA]</dt>
<dd><cite><a href="https://tc39.es/proposal-top-level-await/">Top-Level Await</a></cite>. Ecma International.</dd>

<dt id="refsJSTEMPORAL">[JSTTEMPORAL]</dt>
<dd><cite><a href="https://tc39.es/proposal-temporal/">Temporal</a></cite>. Ecma International.</dd>

<dt id="refsJSON">[JSON]</dt>
<dd><cite><a href="https://tools.ietf.org/html/rfc8259">The JavaScript Object Notation (JSON) Data Interchange Format</a></cite>, T. Bray. IETF.</dd>

Expand Down

0 comments on commit 207b8bd

Please sign in to comment.