Skip to content
Permalink
Browse files
[giow] (0) Define structured cloning for Map and Set
Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=23892
Affected topics: DOM APIs, HTML

git-svn-id: http://svn.whatwg.org/webapps@8374 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Jan 4, 2014
1 parent 0b4aa76 commit cfd60216b383e3fd10e2c867ef70461fe4df850b
Showing with 264 additions and 18 deletions.
  1. +79 −6 complete.html
  2. +79 −6 index
  3. +106 −6 source
@@ -298,7 +298,7 @@

<header class=head id=head><p><a href=http://www.whatwg.org/ class=logo><img width=101 src=/images/logo alt=WHATWG height=101></a></p>
<hgroup><h1 class=allcaps>HTML</h1>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 3 January 2014</h2>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 4 January 2014</h2>
</hgroup><dl><dt><strong>Web developer edition:</strong></dt>
<dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
<dt>Multiple-page version:</dt>
@@ -8156,7 +8156,7 @@ <h4 id=safe-passing-of-structured-data><span class=secno>2.7.6 </span>Safe passi
<li><p>If <var title="">input</var> is a primitive value, then return that value and abort these
steps.</li>

<li><p>Let <var title="">deep clone</var> be false.</li>
<li><p>Let <var title="">deep clone</var> be <i>none</i>.</li>

<li>

@@ -8246,7 +8246,7 @@ <h4 id=safe-passing-of-structured-data><span class=secno>2.7.6 </span>Safe passi

<!--CLEANUP-->
<p>Let <var title="">output</var> be a newly constructed empty <code>Array</code> object whose
<code title="">length</code> is equal to the <code title="">length</code> of <var title="">input</var>, and set <var title="">deep clone</var> to true.</p>
<code title="">length</code> is equal to the <code title="">length</code> of <var title="">input</var>, and set <var title="">deep clone</var> to <i>own</i>.</p>

<p class=note>This means that the length of sparse arrays is preserved.</p>

@@ -8256,7 +8256,17 @@ <h4 id=safe-passing-of-structured-data><span class=secno>2.7.6 </span>Safe passi

<!--CLEANUP-->
<dd><p>Let <var title="">output</var> be a newly constructed empty <code title="">Object</code>
object, and set <var title="">deep clone</var> to true.</dd>
object, and set <var title="">deep clone</var> to <i>own</i>.</dd>

<dt>If <var title="">input</var> is a <code><a href=#the-map-element>Map</a></code> object</dt>

<dd><p>Let <var title="">output</var> be a newly constructed empty <code title="">Map</code>
object, and set <var title="">deep clone</var> to <i><a href=#the-map-element>map</a></i>.</dd>

<dt>If <var title="">input</var> is a <code>Set</code> object</dt>

<dd><p>Let <var title="">output</var> be a newly constructed empty <code title="">Set</code>
object, and set <var title="">deep clone</var> to <i>set</i>.</dd>

<dt>If <var title="">input</var> is an object that another specification defines how to clone</dt>

@@ -8282,7 +8292,70 @@ <h4 id=safe-passing-of-structured-data><span class=secno>2.7.6 </span>Safe passi

<li>

<p>If <var title="">deep clone</var> is set, then, for each enumerable own property in <var title="">input</var>, run the following steps:</p>
<p>If <var title="">deep clone</var> is set to <i><a href=#the-map-element>map</a></i>, then run these substeps. These
substeps use the terminology and typographic conventions used in the JavaScript specification's
definition of Maps. <a href=#refsECMA262>[ECMA262]</a></p>

<ol><li><p>Let <var title="">source</var> be the List that is the value of <var title="">input</var>'s [[MapData]] internal slot, if any. If there is no such slot, then
instead throw a <code><a href=#datacloneerror>DataCloneError</a></code> exception and abort the overall <a href=#structured-clone>structured
clone</a> algorithm. <a href=#refsECMA262>[ECMA262]</a></li>

<li><p>Let <var title="">target</var> be the List that is the value of <var title="">output</var>'s [[MapData]] internal slot.</li>

<li>

<p>For each Record {[[key]], [[value]]} <var title="">entry</var> that is an element of
<var title="">source</var>, run the following substeps:</p>

<ol><li><p>Let <var title="">key</var> have the value obtained from invoking the
<a href=#internal-structured-cloning-algorithm>internal structured cloning algorithm</a> recursively with <var title="">entry</var>.[[key]] as the new "<var title="">input</var>" argument and <var title="">memory</var> as the new "<var title="">memory</var>" argument.</li>

<li><p>Let <var title="">value</var> have the value obtained from invoking the
<a href=#internal-structured-cloning-algorithm>internal structured cloning algorithm</a> recursively with <var title="">entry</var>.[[value]] as the new "<var title="">input</var>" argument and <var title="">memory</var> as the new "<var title="">memory</var>" argument.</li>

<li><p>Let <var title="">new entry</var> be the Record {[[key]]: <var title="">key</var>,
[[value]]: <var title="">value</var>}.</li>

<li><p>Append <var title="">new entry</var> as the last element of <var title="">target</var>.</li>

</ol></li>

<li><p>Set <var title="">deep clone</var> to <i>own</i>.</li>

</ol></li>

<li>

<p>If <var title="">deep clone</var> is set to <i>set</i>, then run these substeps. These
substeps use the terminology and typographic conventions used in the JavaScript specification's
definition of Sets. <a href=#refsECMA262>[ECMA262]</a></p>

<ol><li><p>Let <var title="">source</var> be the List that is the value of <var title="">input</var>'s [[SetData]] internal slot, if any. If there is no such slot, then
instead throw a <code><a href=#datacloneerror>DataCloneError</a></code> exception and abort the overall <a href=#structured-clone>structured
clone</a> algorithm. <a href=#refsECMA262>[ECMA262]</a></li>

<li><p>Let <var title="">target</var> be the List that is the value of <var title="">output</var>'s [[SetData]] internal slot.</li>

<li>

<p>For each <var title="">entry</var> that is an element of <var title="">source</var> that
is not <i>empty</i>, run the following substeps:</p>

<ol><li><p>Let <var title="">new entry</var> have the value obtained from invoking the
<a href=#internal-structured-cloning-algorithm>internal structured cloning algorithm</a> recursively with <var title="">entry</var> as the new "<var title="">input</var>" argument and <var title="">memory</var> as the new "<var title="">memory</var>" argument.</li>

<li><p>Append <var title="">new entry</var> as the last element of <var title="">target</var>.</li>

</ol></li>

<li><p>Set <var title="">deep clone</var> to <i>own</i>.</li>

</ol></li>

<li>

<!--CLEANUP-->
<p>If <var title="">deep clone</var> is set to <i>own</i>, then, for each enumerable own property in <var title="">input</var>, run the following steps:</p>

<ol><li><p>Let <var title="">name</var> be the name of the property.</li>

@@ -101664,7 +101737,7 @@ <h2 class=no-num id=references>References</h2><!--REFS-->
<dd><cite>Recommendation E.163 &mdash; Numbering Plan for The International Telephone Service</cite>, CCITT Blue Book, Fascicle II.2, pp. 128-134, November 1988.</dd>

<dt id=refsECMA262>[ECMA262]</dt>
<dd><cite><a href=http://www.ecma-international.org/publications/standards/Ecma-262.htm>ECMAScript Language Specification</a></cite>. ECMA.</dd>
<dd><cite><a href=http://people.mozilla.org/~jorendorff/es6-draft.html>ECMAScript Language Specification</a></cite>. ECMA.</dd>

<dt id=refsECMA357>[ECMA357]</dt>
<dd>(Non-normative) <cite><a href=http://www.ecma-international.org/publications/standards/Ecma-357.htm>ECMAScript for XML (E4X) Specification</a></cite>. ECMA.</dd>
85 index
@@ -298,7 +298,7 @@

<header class=head id=head><p><a href=http://www.whatwg.org/ class=logo><img width=101 src=/images/logo alt=WHATWG height=101></a></p>
<hgroup><h1 class=allcaps>HTML</h1>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 3 January 2014</h2>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 4 January 2014</h2>
</hgroup><dl><dt><strong>Web developer edition:</strong></dt>
<dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
<dt>Multiple-page version:</dt>
@@ -8156,7 +8156,7 @@ interface <dfn id=transferable>Transferable</dfn> { };
<li><p>If <var title="">input</var> is a primitive value, then return that value and abort these
steps.</li>

<li><p>Let <var title="">deep clone</var> be false.</li>
<li><p>Let <var title="">deep clone</var> be <i>none</i>.</li>

<li>

@@ -8246,7 +8246,7 @@ interface <dfn id=transferable>Transferable</dfn> { };

<!--CLEANUP-->
<p>Let <var title="">output</var> be a newly constructed empty <code>Array</code> object whose
<code title="">length</code> is equal to the <code title="">length</code> of <var title="">input</var>, and set <var title="">deep clone</var> to true.</p>
<code title="">length</code> is equal to the <code title="">length</code> of <var title="">input</var>, and set <var title="">deep clone</var> to <i>own</i>.</p>

<p class=note>This means that the length of sparse arrays is preserved.</p>

@@ -8256,7 +8256,17 @@ interface <dfn id=transferable>Transferable</dfn> { };

<!--CLEANUP-->
<dd><p>Let <var title="">output</var> be a newly constructed empty <code title="">Object</code>
object, and set <var title="">deep clone</var> to true.</dd>
object, and set <var title="">deep clone</var> to <i>own</i>.</dd>

<dt>If <var title="">input</var> is a <code><a href=#the-map-element>Map</a></code> object</dt>

<dd><p>Let <var title="">output</var> be a newly constructed empty <code title="">Map</code>
object, and set <var title="">deep clone</var> to <i><a href=#the-map-element>map</a></i>.</dd>

<dt>If <var title="">input</var> is a <code>Set</code> object</dt>

<dd><p>Let <var title="">output</var> be a newly constructed empty <code title="">Set</code>
object, and set <var title="">deep clone</var> to <i>set</i>.</dd>

<dt>If <var title="">input</var> is an object that another specification defines how to clone</dt>

@@ -8282,7 +8292,70 @@ interface <dfn id=transferable>Transferable</dfn> { };

<li>

<p>If <var title="">deep clone</var> is set, then, for each enumerable own property in <var title="">input</var>, run the following steps:</p>
<p>If <var title="">deep clone</var> is set to <i><a href=#the-map-element>map</a></i>, then run these substeps. These
substeps use the terminology and typographic conventions used in the JavaScript specification's
definition of Maps. <a href=#refsECMA262>[ECMA262]</a></p>

<ol><li><p>Let <var title="">source</var> be the List that is the value of <var title="">input</var>'s [[MapData]] internal slot, if any. If there is no such slot, then
instead throw a <code><a href=#datacloneerror>DataCloneError</a></code> exception and abort the overall <a href=#structured-clone>structured
clone</a> algorithm. <a href=#refsECMA262>[ECMA262]</a></li>

<li><p>Let <var title="">target</var> be the List that is the value of <var title="">output</var>'s [[MapData]] internal slot.</li>

<li>

<p>For each Record {[[key]], [[value]]} <var title="">entry</var> that is an element of
<var title="">source</var>, run the following substeps:</p>

<ol><li><p>Let <var title="">key</var> have the value obtained from invoking the
<a href=#internal-structured-cloning-algorithm>internal structured cloning algorithm</a> recursively with <var title="">entry</var>.[[key]] as the new "<var title="">input</var>" argument and <var title="">memory</var> as the new "<var title="">memory</var>" argument.</li>

<li><p>Let <var title="">value</var> have the value obtained from invoking the
<a href=#internal-structured-cloning-algorithm>internal structured cloning algorithm</a> recursively with <var title="">entry</var>.[[value]] as the new "<var title="">input</var>" argument and <var title="">memory</var> as the new "<var title="">memory</var>" argument.</li>

<li><p>Let <var title="">new entry</var> be the Record {[[key]]: <var title="">key</var>,
[[value]]: <var title="">value</var>}.</li>

<li><p>Append <var title="">new entry</var> as the last element of <var title="">target</var>.</li>

</ol></li>

<li><p>Set <var title="">deep clone</var> to <i>own</i>.</li>

</ol></li>

<li>

<p>If <var title="">deep clone</var> is set to <i>set</i>, then run these substeps. These
substeps use the terminology and typographic conventions used in the JavaScript specification's
definition of Sets. <a href=#refsECMA262>[ECMA262]</a></p>

<ol><li><p>Let <var title="">source</var> be the List that is the value of <var title="">input</var>'s [[SetData]] internal slot, if any. If there is no such slot, then
instead throw a <code><a href=#datacloneerror>DataCloneError</a></code> exception and abort the overall <a href=#structured-clone>structured
clone</a> algorithm. <a href=#refsECMA262>[ECMA262]</a></li>

<li><p>Let <var title="">target</var> be the List that is the value of <var title="">output</var>'s [[SetData]] internal slot.</li>

<li>

<p>For each <var title="">entry</var> that is an element of <var title="">source</var> that
is not <i>empty</i>, run the following substeps:</p>

<ol><li><p>Let <var title="">new entry</var> have the value obtained from invoking the
<a href=#internal-structured-cloning-algorithm>internal structured cloning algorithm</a> recursively with <var title="">entry</var> as the new "<var title="">input</var>" argument and <var title="">memory</var> as the new "<var title="">memory</var>" argument.</li>

<li><p>Append <var title="">new entry</var> as the last element of <var title="">target</var>.</li>

</ol></li>

<li><p>Set <var title="">deep clone</var> to <i>own</i>.</li>

</ol></li>

<li>

<!--CLEANUP-->
<p>If <var title="">deep clone</var> is set to <i>own</i>, then, for each enumerable own property in <var title="">input</var>, run the following steps:</p>

<ol><li><p>Let <var title="">name</var> be the name of the property.</li>

@@ -101664,7 +101737,7 @@ if (s = prompt('What is your name?')) {
<dd><cite>Recommendation E.163 &mdash; Numbering Plan for The International Telephone Service</cite>, CCITT Blue Book, Fascicle II.2, pp. 128-134, November 1988.</dd>

<dt id=refsECMA262>[ECMA262]</dt>
<dd><cite><a href=http://www.ecma-international.org/publications/standards/Ecma-262.htm>ECMAScript Language Specification</a></cite>. ECMA.</dd>
<dd><cite><a href=http://people.mozilla.org/~jorendorff/es6-draft.html>ECMAScript Language Specification</a></cite>. ECMA.</dd>

<dt id=refsECMA357>[ECMA357]</dt>
<dd>(Non-normative) <cite><a href=http://www.ecma-international.org/publications/standards/Ecma-357.htm>ECMAScript for XML (E4X) Specification</a></cite>. ECMA.</dd>

0 comments on commit cfd6021

Please sign in to comment.