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 18, 2018
1 parent fc82f4f commit 17ff03e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion source
Original file line number Diff line number Diff line change
Expand Up @@ -8127,7 +8127,7 @@ 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, BigInt, 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 +8141,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 [[BigIntValue]] internal slot, then set
<var>serialized</var> to { [[Type]]: "BigInt", [[BigIntValue]]: <var>value</var>.[[BigIntValue]]
}.</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 +8550,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 [[BigIntValue]] internal slot value is
<var>serialized</var>.[[BigIntValue]].</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

0 comments on commit 17ff03e

Please sign in to comment.