Skip to content

Commit

Permalink
Normative: Permit serialization of BigInt wrappers
Browse files Browse the repository at this point in the history
The goal of this PR is to integrate BigInt with HTML serialization.

This patch
- Adds BigInt to the "safe list" of primitives permitted for
  serialization.
- Adds serialization of BigInt wrappers, analogous to other wrappers.

Note that BigInt, like (the unserializable) Symbol does not have a
new-able constructor: use of wrappers is explicitly discouraged by
the specification. Nevertheless, this patch adds serialization support
for consistency with other wrappers.

web-platform-tests against postMessage on BigInt are out for review in
web-platform-tests/wpt#9565
  • Loading branch information
littledan committed Feb 22, 2018
1 parent fc82f4f commit f0d3238
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion source
Original file line number Diff line number Diff line change
Expand Up @@ -3082,6 +3082,15 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li>The <dfn data-x="js-HostGetImportMetaProperties" data-x-href="https://tc39.github.io/proposal-import-meta/#sec-hostgetimportmetaproperties">HostGetImportMetaProperties</dfn> abstract operation</li>
</ul>

<p>Users agents that support JavaScript must also implement the <cite>BigInt</cite>
proposal. The following terms are defined there, and used in this specification: <ref
spec=JSBIGINT></p>

<ul class="brief">
<li>The <dfn data-x="js-BigInt" data-x-href="https://tc39.github.io/proposal-bigint/#sec-ecmascript-language-types-bigint-type">BigInt</dfn> type.</li>
<li>The <dfn data-x="js-BigIntData" data-x-href="https://tc39.github.io/proposal-bigint/#sec-toobject">[[BigIntData]]</dfn> internal slot</li>
</ul>

</dd>


Expand Down Expand Up @@ -8127,7 +8136,8 @@ interface <dfn>DOMStringList</dfn> {
<li><p>Let <var>deep</var> be false.</p></li>

<li><p>If <span data-x="js-Type">Type</span>(<var>value</var>) is Undefined, Null, Boolean,
String, or Number, then return { [[Type]]: "primitive", [[Value]]: <var>value</var> }.</p></li>
Number, <span data-x="js-BigInt">BigInt</span>, or String, then return { [[Type]]: "primitive",
[[Value]]: <var>value</var> }.</p></li>

<li><p>If <span data-x="js-Type">Type</span>(<var>value</var>) is Symbol, then throw a
<span>"<code>DataCloneError</code>"</span> <code>DOMException</code>.</p></li>
Expand All @@ -8141,6 +8151,10 @@ interface <dfn>DOMStringList</dfn> {
<var>serialized</var> to { [[Type]]: "Number", [[NumberData]]: <var>value</var>.[[NumberData]]
}.</p></li>

<li><p>Otherwise, if <var>value</var> has a <span data-x="js-BigIntData">[[BigIntData]]</span>
internal slot, then set <var>serialized</var> to { [[Type]]: "BigInt", [[BigIntData]]:
<var>value</var>.<span data-x="js-BigIntData">[[BigIntData]]</span> }.</p></li>

<li><p>Otherwise, if <var>value</var> has a [[StringData]] internal slot, then set
<var>serialized</var> to { [[Type]]: "String", [[StringData]]: <var>value</var>.[[StringData]]
}.</p></li>
Expand Down Expand Up @@ -8546,6 +8560,10 @@ o.myself = o;</pre>
<var>targetRealm</var> whose [[NumberData]] internal slot value is
<var>serialized</var>.[[NumberData]].</p></li>

<li><p>Otherwise, if <var>serialized</var>.[[Type]] is "BigInt", then set <var>value</var> to a new BigInt object in
<var>targetRealm</var> whose <span data-x="js-BigIntData">[[BigIntData]]</span> internal slot value is
<var>serialized</var>.[[BigIntData]].</p></li>

<li><p>Otherwise, if <var>serialized</var>.[[Type]] is "String", then set <var>value</var> to a new String object in
<var>targetRealm</var> whose [[StringData]] internal slot value is
<var>serialized</var>.[[StringData]].</p></li>
Expand Down Expand Up @@ -120209,6 +120227,9 @@ INSERT INTERFACES HERE
<dt id="refsJPEG">[JPEG]</dt>
<dd><cite><a href="https://www.w3.org/Graphics/JPEG/jfif3.pdf">JPEG File Interchange Format</a></cite>, E. Hamilton.</dd>

<dt id="refsJSBIGINT">[JSBIGINT]</dt>
<dd><cite><a href="https://tc39.github.io/proposal-bigint/">BigInt</a></cite>. Ecma International.</dd>

<dt id="refsJSIMPORT">[JSIMPORT]</dt>
<dd><cite><a href="https://tc39.github.io/proposal-dynamic-import/">import()</a></cite>. Ecma International.</dd>

Expand Down

0 comments on commit f0d3238

Please sign in to comment.