[html5] r5587 - [giow] (1) Make the structured clone algorithm support cycles. Fixing http://www [...]

whatwg at whatwg.org whatwg at whatwg.org
Wed Oct 6 15:41:22 PDT 2010


Author: ianh
Date: 2010-10-06 15:41:20 -0700 (Wed, 06 Oct 2010)
New Revision: 5587

Modified:
   complete.html
   index
   source
Log:
[giow] (1) Make the structured clone algorithm support cycles.
Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10878

Modified: complete.html
===================================================================
--- complete.html	2010-10-06 21:00:48 UTC (rev 5586)
+++ complete.html	2010-10-06 22:41:20 UTC (rev 5587)
@@ -7614,8 +7614,11 @@
   <ol><li><p>Let <var title="">input</var> be the object being
    cloned.</li>
 
-   <li><p>Let <var title="">memory</var> be a list of objects,
-   initially empty. (This is used to catch cycles.)</li>
+   <li><p>Let <var title="">memory</var> be an association list of
+   pairs of objects, initially empty. This is used to handle duplicate
+   references. In each pair of objects, one is called the
+   <em>source</em> object and the other the <em>destination</em>
+   object.</li>
 
    <li><p>Let <var title="">output</var> be the object resulting from
    calling the <a href=#internal-structured-cloning-algorithm>internal structured cloning algorithm</a> with
@@ -7624,124 +7627,110 @@
    <li><p>Return <var title="">output</var>.</li>
 
   </ol><p>The <dfn id=internal-structured-cloning-algorithm>internal structured cloning algorithm</dfn> is always
-  called with two arguments, <var title="">input</var> and <var title="">memory</var>, and its behavior depends on the type of <var title="">input</var>, as follows:</p>
+  called with two arguments, <var title="">input</var> and <var title="">memory</var>, and its behavior is as follows:</p>
 
-  <dl class=switch><dt>If <var title="">input</var> is the undefined value</dt>
+  <ol><li><p>If <var title="">input</var> is the source object of a pair
+   of objects in <var title="">memory</var>, then return the
+   destination object in that pair of objects and abort these
+   steps.</li>
 
-   <dd><p>Return the undefined value.</dd>
+   <li><p>If <var title="">input</var> is a primitive value, then
+   return that value and abort these steps.</li>
 
-   <dt>If <var title="">input</var> is the null value</dt>
+   <li>
 
-   <dd><p>Return the null value.</dd>
+    <p>The <var title="">input</var> value is an object. Jump to the
+    appropriate step below:</p>
 
-   <dt>If <var title="">input</var> is the false value</dt>
+    <dl class=switch><dt>If <var title="">input</var> is a Boolean object</dt>
 
-   <dd><p>Return the false value.</dd>
+     <dd><p>Let <var title="">output</var> be a newly constructed Boolean object with the same value as <var title="">input</var>.</dd>
 
-   <dt>If <var title="">input</var> is the true value</dt>
+     <dt>If <var title="">input</var> is a Number object</dt>
 
-   <dd><p>Return the true value.</dd>
+     <dd><p>Let <var title="">output</var> be a newly constructed Number object with the same value as <var title="">input</var>.</dd>
 
-   <dt>If <var title="">input</var> is a number</dt>
+     <dt>If <var title="">input</var> is a String object</dt>
 
-   <dd><p>Return the same number.</dd>
+     <dd><p>Let <var title="">output</var> be a newly constructed String object with the same value as <var title="">input</var>.</dd>
 
-   <dt>If <var title="">input</var> is a string</dt>
+     <dt>If <var title="">input</var> is a <code>Date</code> object</dt>
 
-   <dd><p>Return the same string.</dd>
+     <dd><p>Let <var title="">output</var> be a newly constructed <code>Date</code> object with the same value as <var title="">input</var>.</dd>
 
-   <dt>If <var title="">input</var> is a Boolean object</dt>
+     <dt>If <var title="">input</var> is a <code>RegExp</code> object</dt>
 
-   <dd><p>Return a newly constructed Boolean object with the same value as <var title="">input</var>.</dd>
+     <dd>
 
-   <dt>If <var title="">input</var> is a Number object</dt>
+      <p>Let <var title="">output</var> be a newly constructed <code>RegExp</code> object with the same pattern and flags as <var title="">input</var>.</p>
 
-   <dd><p>Return a newly constructed Number object with the same value as <var title="">input</var>.</dd>
+      <p class=note>The value of the <code title="">lastIndex</code> property is not copied.</p>
 
-   <dt>If <var title="">input</var> is a String object</dt>
+     </dd>
 
-   <dd><p>Return a newly constructed String object with the same value as <var title="">input</var>.</dd>
+     <dt>If <var title="">input</var> is a <code><a href=#imagedata>ImageData</a></code> object</dt>
 
-   <dt>If <var title="">input</var> is a <code>Date</code> object</dt>
+     <dd><p>Let <var title="">output</var> be a newly constructed <code><a href=#imagedata>ImageData</a></code> object
+     with the same <code title=dom-imagedata-width><a href=#dom-imagedata-width>width</a></code> and
+     <code title=dom-imagedata-height><a href=#dom-imagedata-height>height</a></code> as <var title="">input</var>, and with a newly constructed
+     <code><a href=#canvaspixelarray>CanvasPixelArray</a></code> for its <code title=dom-imagedata-data><a href=#dom-imagedata-data>data</a></code> attribute, with the same
+     <code title=dom-canvaspixelarray-length><a href=#dom-canvaspixelarray-length>length</a></code> and pixel
+     values as the <var title="">input</var>'s.</dd>
 
-   <dd><p>Return a newly constructed <code>Date</code> object with the same value as <var title="">input</var>.</dd>
+     <dt>If <var title="">input</var> is a <code>File</code> object</dt>
 
-   <dt>If <var title="">input</var> is a <code>RegExp</code> object</dt>
+     <dd><p>Let <var title="">output</var> be a newly constructed <code>File</code> object corresponding to the same underlying data.</dd>
 
-   <dd>
+     <dt>If <var title="">input</var> is a <code>Blob</code> object</dt>
 
-    <p>Return a newly constructed <code>RegExp</code> object with the same pattern and flags as <var title="">input</var>.</p>
+     <dd><p>Let <var title="">output</var> be a newly constructed <code>Blob</code> object corresponding to the same underlying data.</dd>
 
-    <p class=note>The value of the <code title="">lastIndex</code> property is not copied.</p>
+     <dt>If <var title="">input</var> is a <code>FileList</code> object</dt>
 
-   </dd>
+     <dd><p>Let <var title="">output</var> be a newly constructed <code>FileList</code> object containing a list of newly constructed <code>File</code> objects corresponding to the same underlying data as those in <var title="">input</var>, maintaining their relative order.</dd>
 
-   <dt>If <var title="">input</var> is a <code><a href=#imagedata>ImageData</a></code> object</dt>
+     <dt>If <var title="">input</var> is an Array object</dt>
 
-   <dd><p>Return a newly constructed <code><a href=#imagedata>ImageData</a></code> object
-   with the same <code title=dom-imagedata-width><a href=#dom-imagedata-width>width</a></code> and
-   <code title=dom-imagedata-height><a href=#dom-imagedata-height>height</a></code> as <var title="">input</var>, and with a newly constructed
-   <code><a href=#canvaspixelarray>CanvasPixelArray</a></code> for its <code title=dom-imagedata-data><a href=#dom-imagedata-data>data</a></code> attribute, with the same
-   <code title=dom-canvaspixelarray-length><a href=#dom-canvaspixelarray-length>length</a></code> and pixel
-   values as the <var title="">input</var>'s.</dd>
+     <dd><p>Let <var title="">output</var> be a newly constructed empty <code>Array</code> object.</dd>
 
-   <dt>If <var title="">input</var> is a <code>File</code> object</dt>
+     <dt>If <var title="">input</var> is an Object object</dt>
 
-   <dd><p>Return a newly constructed <code>File</code> object corresponding to the same underlying data.</dd>
+     <dd><p>Let <var title="">output</var> be a newly constructed empty <code><a href=#the-object-element>Object</a></code> object.</dd>
 
-   <dt>If <var title="">input</var> is a <code>Blob</code> object</dt>
+     <dt>If <var title="">input</var> is another native object type (e.g. <code>Error</code>, <code><a href=#function>Function</a></code>)</dt>
+     <dt>If <var title="">input</var> is a host object (e.g. a DOM node)</dt>
 
-   <dd><p>Return a newly constructed <code>Blob</code> object corresponding to the same underlying data.</dd>
+     <dd><p>Throw a <code><a href=#data_clone_err>DATA_CLONE_ERR</a></code> exception and abort
+     the overall <a href=#structured-clone>structured clone</a> algorithm.</dd>
 
-   <dt>If <var title="">input</var> is a <code>FileList</code> object</dt>
+    </dl></li>
 
-   <dd><p>Return a newly constructed <code>FileList</code> object containing a list of newly constructed <code>File</code> objects corresponding to the same underlying data as those in <var title="">input</var>, maintaining their relative order.</dd>
+   <li><p>Add a mapping from <var title="">input</var> (the source
+   object) to <var title="">output</var> (the destination object) to
+   <var title="">memory</var>.</li>
 
-   <dt>If <var title="">input</var> is an Array object</dt>
-   <dt>If <var title="">input</var> is an Object object</dt>
+   <li>
 
-   <dd>
+    <p>If <var title="">input</var> is an Array object or an Object
+    object, then, for each enumerable property in <var title="">input</var>, add a corresponding property to <var title="">output</var> having the same name, and having a value
+    created from invoking the <a href=#internal-structured-cloning-algorithm>internal structured cloning
+    algorithm</a> recursively with the value of the property as the
+    "<var title="">input</var>" argument and <var title="">memory</var> as the "<var title="">memory</var>"
+    argument. The order of the properties in the <var title="">input</var> and <var title="">output</var> objects must
+    be the same.</p>
 
-    <ol><li><p>If <var title="">input</var> is in <var title="">memory</var>, then throw a <code><a href=#data_clone_err>DATA_CLONE_ERR</a></code>
-     exception and abort the overall <a href=#structured-clone>structured clone</a>
-     algorithm.</li>
+    <p class=note>This does not walk the prototype chain.</p>
 
-     <li><p>Otherwise, let <var title="">new memory</var> be a list
-     consisting of the items in <var title="">memory</var> with the
-     addition of <var title="">input</var>.</li>
+   </li>
 
-     <li><p>Create a new object, <var title="">output</var>, of the
-     same type as <var title="">input</var>: either an Array or an
-     Object.</li>
+   <li><p>Return <var title="">output</var>.</li>
 
-     <li>
+  </ol><p class=note>This algorithm preserves cycles and preserves the
+  identity of duplicate objects in graphs.</p>
 
-      <p>For each enumerable property in <var title="">input</var>,
-      add a corresponding property to <var title="">output</var>
-      having the same name, and having a value created from invoking
-      the <a href=#internal-structured-cloning-algorithm>internal structured cloning algorithm</a>
-      recursively with the value of the property as the "<var title="">input</var>" argument and <var title="">new
-      memory</var> as the "<var title="">memory</var>" argument. The
-      order of the properties in the <var title="">input</var> and
-      <var title="">output</var> objects must be the same.</p>
+  </div>
 
-      <p class=note>This does not walk the prototype chain.</p>
 
-     </li>
-
-     <li><p>Return <var title="">output</var>.</li>
-
-    </ol></dd>
-
-   <dt>If <var title="">input</var> is another native object type (e.g. <code>Error</code>, <code><a href=#function>Function</a></code>)</dt>
-   <dt>If <var title="">input</var> is a host object (e.g. a DOM node)</dt>
-
-   <dd><p>Throw a <code><a href=#data_clone_err>DATA_CLONE_ERR</a></code> exception and abort the
-   overall <a href=#structured-clone>structured clone</a> algorithm.</dd>
-
-  </dl></div>
-
-
   <h4 id=domstringmap-0><span class=secno>2.8.6 </span>DOMStringMap</h4>
 
   <p>The <code><a href=#domstringmap>DOMStringMap</a></code> interface represents a set of

Modified: index
===================================================================
--- index	2010-10-06 21:00:48 UTC (rev 5586)
+++ index	2010-10-06 22:41:20 UTC (rev 5587)
@@ -7591,8 +7591,11 @@
   <ol><li><p>Let <var title="">input</var> be the object being
    cloned.</li>
 
-   <li><p>Let <var title="">memory</var> be a list of objects,
-   initially empty. (This is used to catch cycles.)</li>
+   <li><p>Let <var title="">memory</var> be an association list of
+   pairs of objects, initially empty. This is used to handle duplicate
+   references. In each pair of objects, one is called the
+   <em>source</em> object and the other the <em>destination</em>
+   object.</li>
 
    <li><p>Let <var title="">output</var> be the object resulting from
    calling the <a href=#internal-structured-cloning-algorithm>internal structured cloning algorithm</a> with
@@ -7601,124 +7604,110 @@
    <li><p>Return <var title="">output</var>.</li>
 
   </ol><p>The <dfn id=internal-structured-cloning-algorithm>internal structured cloning algorithm</dfn> is always
-  called with two arguments, <var title="">input</var> and <var title="">memory</var>, and its behavior depends on the type of <var title="">input</var>, as follows:</p>
+  called with two arguments, <var title="">input</var> and <var title="">memory</var>, and its behavior is as follows:</p>
 
-  <dl class=switch><dt>If <var title="">input</var> is the undefined value</dt>
+  <ol><li><p>If <var title="">input</var> is the source object of a pair
+   of objects in <var title="">memory</var>, then return the
+   destination object in that pair of objects and abort these
+   steps.</li>
 
-   <dd><p>Return the undefined value.</dd>
+   <li><p>If <var title="">input</var> is a primitive value, then
+   return that value and abort these steps.</li>
 
-   <dt>If <var title="">input</var> is the null value</dt>
+   <li>
 
-   <dd><p>Return the null value.</dd>
+    <p>The <var title="">input</var> value is an object. Jump to the
+    appropriate step below:</p>
 
-   <dt>If <var title="">input</var> is the false value</dt>
+    <dl class=switch><dt>If <var title="">input</var> is a Boolean object</dt>
 
-   <dd><p>Return the false value.</dd>
+     <dd><p>Let <var title="">output</var> be a newly constructed Boolean object with the same value as <var title="">input</var>.</dd>
 
-   <dt>If <var title="">input</var> is the true value</dt>
+     <dt>If <var title="">input</var> is a Number object</dt>
 
-   <dd><p>Return the true value.</dd>
+     <dd><p>Let <var title="">output</var> be a newly constructed Number object with the same value as <var title="">input</var>.</dd>
 
-   <dt>If <var title="">input</var> is a number</dt>
+     <dt>If <var title="">input</var> is a String object</dt>
 
-   <dd><p>Return the same number.</dd>
+     <dd><p>Let <var title="">output</var> be a newly constructed String object with the same value as <var title="">input</var>.</dd>
 
-   <dt>If <var title="">input</var> is a string</dt>
+     <dt>If <var title="">input</var> is a <code>Date</code> object</dt>
 
-   <dd><p>Return the same string.</dd>
+     <dd><p>Let <var title="">output</var> be a newly constructed <code>Date</code> object with the same value as <var title="">input</var>.</dd>
 
-   <dt>If <var title="">input</var> is a Boolean object</dt>
+     <dt>If <var title="">input</var> is a <code>RegExp</code> object</dt>
 
-   <dd><p>Return a newly constructed Boolean object with the same value as <var title="">input</var>.</dd>
+     <dd>
 
-   <dt>If <var title="">input</var> is a Number object</dt>
+      <p>Let <var title="">output</var> be a newly constructed <code>RegExp</code> object with the same pattern and flags as <var title="">input</var>.</p>
 
-   <dd><p>Return a newly constructed Number object with the same value as <var title="">input</var>.</dd>
+      <p class=note>The value of the <code title="">lastIndex</code> property is not copied.</p>
 
-   <dt>If <var title="">input</var> is a String object</dt>
+     </dd>
 
-   <dd><p>Return a newly constructed String object with the same value as <var title="">input</var>.</dd>
+     <dt>If <var title="">input</var> is a <code><a href=#imagedata>ImageData</a></code> object</dt>
 
-   <dt>If <var title="">input</var> is a <code>Date</code> object</dt>
+     <dd><p>Let <var title="">output</var> be a newly constructed <code><a href=#imagedata>ImageData</a></code> object
+     with the same <code title=dom-imagedata-width><a href=#dom-imagedata-width>width</a></code> and
+     <code title=dom-imagedata-height><a href=#dom-imagedata-height>height</a></code> as <var title="">input</var>, and with a newly constructed
+     <code><a href=#canvaspixelarray>CanvasPixelArray</a></code> for its <code title=dom-imagedata-data><a href=#dom-imagedata-data>data</a></code> attribute, with the same
+     <code title=dom-canvaspixelarray-length><a href=#dom-canvaspixelarray-length>length</a></code> and pixel
+     values as the <var title="">input</var>'s.</dd>
 
-   <dd><p>Return a newly constructed <code>Date</code> object with the same value as <var title="">input</var>.</dd>
+     <dt>If <var title="">input</var> is a <code>File</code> object</dt>
 
-   <dt>If <var title="">input</var> is a <code>RegExp</code> object</dt>
+     <dd><p>Let <var title="">output</var> be a newly constructed <code>File</code> object corresponding to the same underlying data.</dd>
 
-   <dd>
+     <dt>If <var title="">input</var> is a <code>Blob</code> object</dt>
 
-    <p>Return a newly constructed <code>RegExp</code> object with the same pattern and flags as <var title="">input</var>.</p>
+     <dd><p>Let <var title="">output</var> be a newly constructed <code>Blob</code> object corresponding to the same underlying data.</dd>
 
-    <p class=note>The value of the <code title="">lastIndex</code> property is not copied.</p>
+     <dt>If <var title="">input</var> is a <code>FileList</code> object</dt>
 
-   </dd>
+     <dd><p>Let <var title="">output</var> be a newly constructed <code>FileList</code> object containing a list of newly constructed <code>File</code> objects corresponding to the same underlying data as those in <var title="">input</var>, maintaining their relative order.</dd>
 
-   <dt>If <var title="">input</var> is a <code><a href=#imagedata>ImageData</a></code> object</dt>
+     <dt>If <var title="">input</var> is an Array object</dt>
 
-   <dd><p>Return a newly constructed <code><a href=#imagedata>ImageData</a></code> object
-   with the same <code title=dom-imagedata-width><a href=#dom-imagedata-width>width</a></code> and
-   <code title=dom-imagedata-height><a href=#dom-imagedata-height>height</a></code> as <var title="">input</var>, and with a newly constructed
-   <code><a href=#canvaspixelarray>CanvasPixelArray</a></code> for its <code title=dom-imagedata-data><a href=#dom-imagedata-data>data</a></code> attribute, with the same
-   <code title=dom-canvaspixelarray-length><a href=#dom-canvaspixelarray-length>length</a></code> and pixel
-   values as the <var title="">input</var>'s.</dd>
+     <dd><p>Let <var title="">output</var> be a newly constructed empty <code>Array</code> object.</dd>
 
-   <dt>If <var title="">input</var> is a <code>File</code> object</dt>
+     <dt>If <var title="">input</var> is an Object object</dt>
 
-   <dd><p>Return a newly constructed <code>File</code> object corresponding to the same underlying data.</dd>
+     <dd><p>Let <var title="">output</var> be a newly constructed empty <code><a href=#the-object-element>Object</a></code> object.</dd>
 
-   <dt>If <var title="">input</var> is a <code>Blob</code> object</dt>
+     <dt>If <var title="">input</var> is another native object type (e.g. <code>Error</code>, <code><a href=#function>Function</a></code>)</dt>
+     <dt>If <var title="">input</var> is a host object (e.g. a DOM node)</dt>
 
-   <dd><p>Return a newly constructed <code>Blob</code> object corresponding to the same underlying data.</dd>
+     <dd><p>Throw a <code><a href=#data_clone_err>DATA_CLONE_ERR</a></code> exception and abort
+     the overall <a href=#structured-clone>structured clone</a> algorithm.</dd>
 
-   <dt>If <var title="">input</var> is a <code>FileList</code> object</dt>
+    </dl></li>
 
-   <dd><p>Return a newly constructed <code>FileList</code> object containing a list of newly constructed <code>File</code> objects corresponding to the same underlying data as those in <var title="">input</var>, maintaining their relative order.</dd>
+   <li><p>Add a mapping from <var title="">input</var> (the source
+   object) to <var title="">output</var> (the destination object) to
+   <var title="">memory</var>.</li>
 
-   <dt>If <var title="">input</var> is an Array object</dt>
-   <dt>If <var title="">input</var> is an Object object</dt>
+   <li>
 
-   <dd>
+    <p>If <var title="">input</var> is an Array object or an Object
+    object, then, for each enumerable property in <var title="">input</var>, add a corresponding property to <var title="">output</var> having the same name, and having a value
+    created from invoking the <a href=#internal-structured-cloning-algorithm>internal structured cloning
+    algorithm</a> recursively with the value of the property as the
+    "<var title="">input</var>" argument and <var title="">memory</var> as the "<var title="">memory</var>"
+    argument. The order of the properties in the <var title="">input</var> and <var title="">output</var> objects must
+    be the same.</p>
 
-    <ol><li><p>If <var title="">input</var> is in <var title="">memory</var>, then throw a <code><a href=#data_clone_err>DATA_CLONE_ERR</a></code>
-     exception and abort the overall <a href=#structured-clone>structured clone</a>
-     algorithm.</li>
+    <p class=note>This does not walk the prototype chain.</p>
 
-     <li><p>Otherwise, let <var title="">new memory</var> be a list
-     consisting of the items in <var title="">memory</var> with the
-     addition of <var title="">input</var>.</li>
+   </li>
 
-     <li><p>Create a new object, <var title="">output</var>, of the
-     same type as <var title="">input</var>: either an Array or an
-     Object.</li>
+   <li><p>Return <var title="">output</var>.</li>
 
-     <li>
+  </ol><p class=note>This algorithm preserves cycles and preserves the
+  identity of duplicate objects in graphs.</p>
 
-      <p>For each enumerable property in <var title="">input</var>,
-      add a corresponding property to <var title="">output</var>
-      having the same name, and having a value created from invoking
-      the <a href=#internal-structured-cloning-algorithm>internal structured cloning algorithm</a>
-      recursively with the value of the property as the "<var title="">input</var>" argument and <var title="">new
-      memory</var> as the "<var title="">memory</var>" argument. The
-      order of the properties in the <var title="">input</var> and
-      <var title="">output</var> objects must be the same.</p>
+  </div>
 
-      <p class=note>This does not walk the prototype chain.</p>
 
-     </li>
-
-     <li><p>Return <var title="">output</var>.</li>
-
-    </ol></dd>
-
-   <dt>If <var title="">input</var> is another native object type (e.g. <code>Error</code>, <code><a href=#function>Function</a></code>)</dt>
-   <dt>If <var title="">input</var> is a host object (e.g. a DOM node)</dt>
-
-   <dd><p>Throw a <code><a href=#data_clone_err>DATA_CLONE_ERR</a></code> exception and abort the
-   overall <a href=#structured-clone>structured clone</a> algorithm.</dd>
-
-  </dl></div>
-
-
   <h4 id=domstringmap-0><span class=secno>2.8.6 </span>DOMStringMap</h4>
 
   <p>The <code><a href=#domstringmap>DOMStringMap</a></code> interface represents a set of

Modified: source
===================================================================
--- source	2010-10-06 21:00:48 UTC (rev 5586)
+++ source	2010-10-06 22:41:20 UTC (rev 5587)
@@ -7461,8 +7461,11 @@
    <li><p>Let <var title="">input</var> be the object being
    cloned.</p></li>
 
-   <li><p>Let <var title="">memory</var> be a list of objects,
-   initially empty. (This is used to catch cycles.)</p></li>
+   <li><p>Let <var title="">memory</var> be an association list of
+   pairs of objects, initially empty. This is used to handle duplicate
+   references. In each pair of objects, one is called the
+   <em>source</em> object and the other the <em>destination</em>
+   object.</p></li>
 
    <li><p>Let <var title="">output</var> be the object resulting from
    calling the <span>internal structured cloning algorithm</span> with
@@ -7474,134 +7477,121 @@
 
   <p>The <dfn>internal structured cloning algorithm</dfn> is always
   called with two arguments, <var title="">input</var> and <var
-  title="">memory</var>, and its behavior depends on the type of <var
-  title="">input</var>, as follows:</p>
+  title="">memory</var>, and its behavior is as follows:</p>
 
-  <dl class="switch">
+  <ol>
 
-   <dt>If <var title="">input</var> is the undefined value</dt>
+   <li><p>If <var title="">input</var> is the source object of a pair
+   of objects in <var title="">memory</var>, then return the
+   destination object in that pair of objects and abort these
+   steps.</p></li>
 
-   <dd><p>Return the undefined value.</p></dd>
+   <li><p>If <var title="">input</var> is a primitive value, then
+   return that value and abort these steps.</p></li>
 
-   <dt>If <var title="">input</var> is the null value</dt>
+   <li>
 
-   <dd><p>Return the null value.</p></dd>
+    <p>The <var title="">input</var> value is an object. Jump to the
+    appropriate step below:</p>
 
-   <dt>If <var title="">input</var> is the false value</dt>
+    <dl class="switch">
 
-   <dd><p>Return the false value.</p></dd>
+     <dt>If <var title="">input</var> is a Boolean object</dt>
 
-   <dt>If <var title="">input</var> is the true value</dt>
+     <dd><p>Let <var title="">output</var> be a newly constructed Boolean object with the same value as <var title="">input</var>.</p></dd>
 
-   <dd><p>Return the true value.</p></dd>
+     <dt>If <var title="">input</var> is a Number object</dt>
 
-   <dt>If <var title="">input</var> is a number</dt>
+     <dd><p>Let <var title="">output</var> be a newly constructed Number object with the same value as <var title="">input</var>.</p></dd>
 
-   <dd><p>Return the same number.</p></dd>
+     <dt>If <var title="">input</var> is a String object</dt>
 
-   <dt>If <var title="">input</var> is a string</dt>
+     <dd><p>Let <var title="">output</var> be a newly constructed String object with the same value as <var title="">input</var>.</p></dd>
 
-   <dd><p>Return the same string.</p></dd>
+     <dt>If <var title="">input</var> is a <code>Date</code> object</dt>
 
-   <dt>If <var title="">input</var> is a Boolean object</dt>
+     <dd><p>Let <var title="">output</var> be a newly constructed <code>Date</code> object with the same value as <var title="">input</var>.</p></dd>
 
-   <dd><p>Return a newly constructed Boolean object with the same value as <var title="">input</var>.</p></dd>
+     <dt>If <var title="">input</var> is a <code>RegExp</code> object</dt>
 
-   <dt>If <var title="">input</var> is a Number object</dt>
+     <dd>
 
-   <dd><p>Return a newly constructed Number object with the same value as <var title="">input</var>.</p></dd>
+      <p>Let <var title="">output</var> be a newly constructed <code>RegExp</code> object with the same pattern and flags as <var title="">input</var>.</p>
 
-   <dt>If <var title="">input</var> is a String object</dt>
+      <p class="note">The value of the <code title="">lastIndex</code> property is not copied.</p>
 
-   <dd><p>Return a newly constructed String object with the same value as <var title="">input</var>.</p></dd>
+     </dd>
 
-   <dt>If <var title="">input</var> is a <code>Date</code> object</dt>
+     <dt>If <var title="">input</var> is a <code>ImageData</code> object</dt>
 
-   <dd><p>Return a newly constructed <code>Date</code> object with the same value as <var title="">input</var>.</p></dd>
+     <dd><p>Let <var title="">output</var> be a newly constructed <code>ImageData</code> object
+     with the same <code title="dom-imagedata-width">width</code> and
+     <code title="dom-imagedata-height">height</code> as <var
+     title="">input</var>, and with a newly constructed
+     <code>CanvasPixelArray</code> for its <code
+     title="dom-imagedata-data">data</code> attribute, with the same
+     <code title="dom-canvaspixelarray-length">length</code> and pixel
+     values as the <var title="">input</var>'s.</p></dd>
 
-   <dt>If <var title="">input</var> is a <code>RegExp</code> object</dt>
+     <dt>If <var title="">input</var> is a <code>File</code> object</dt>
 
-   <dd>
+     <dd><p>Let <var title="">output</var> be a newly constructed <code>File</code> object corresponding to the same underlying data.</p></dd>
 
-    <p>Return a newly constructed <code>RegExp</code> object with the same pattern and flags as <var title="">input</var>.</p>
+     <dt>If <var title="">input</var> is a <code>Blob</code> object</dt>
 
-    <p class="note">The value of the <code title="">lastIndex</code> property is not copied.</p>
+     <dd><p>Let <var title="">output</var> be a newly constructed <code>Blob</code> object corresponding to the same underlying data.</p></dd>
 
-   </dd>
+     <dt>If <var title="">input</var> is a <code>FileList</code> object</dt>
 
-   <dt>If <var title="">input</var> is a <code>ImageData</code> object</dt>
+     <dd><p>Let <var title="">output</var> be a newly constructed <code>FileList</code> object containing a list of newly constructed <code>File</code> objects corresponding to the same underlying data as those in <var title="">input</var>, maintaining their relative order.</p></dd>
 
-   <dd><p>Return a newly constructed <code>ImageData</code> object
-   with the same <code title="dom-imagedata-width">width</code> and
-   <code title="dom-imagedata-height">height</code> as <var
-   title="">input</var>, and with a newly constructed
-   <code>CanvasPixelArray</code> for its <code
-   title="dom-imagedata-data">data</code> attribute, with the same
-   <code title="dom-canvaspixelarray-length">length</code> and pixel
-   values as the <var title="">input</var>'s.</p></dd>
+     <dt>If <var title="">input</var> is an Array object</dt>
 
-   <dt>If <var title="">input</var> is a <code>File</code> object</dt>
+     <dd><p>Let <var title="">output</var> be a newly constructed empty <code>Array</code> object.</p></dd>
 
-   <dd><p>Return a newly constructed <code>File</code> object corresponding to the same underlying data.</p></dd>
+     <dt>If <var title="">input</var> is an Object object</dt>
 
-   <dt>If <var title="">input</var> is a <code>Blob</code> object</dt>
+     <dd><p>Let <var title="">output</var> be a newly constructed empty <code>Object</code> object.</p></dd>
 
-   <dd><p>Return a newly constructed <code>Blob</code> object corresponding to the same underlying data.</p></dd>
+     <dt>If <var title="">input</var> is another native object type (e.g. <code>Error</code>, <code>Function</code>)</dt>
+     <dt>If <var title="">input</var> is a host object (e.g. a DOM node)</dt>
 
-   <dt>If <var title="">input</var> is a <code>FileList</code> object</dt>
+     <dd><p>Throw a <code>DATA_CLONE_ERR</code> exception and abort
+     the overall <span>structured clone</span> algorithm.</p></dd>
 
-   <dd><p>Return a newly constructed <code>FileList</code> object containing a list of newly constructed <code>File</code> objects corresponding to the same underlying data as those in <var title="">input</var>, maintaining their relative order.</p></dd>
+    </dl>
 
-   <dt>If <var title="">input</var> is an Array object</dt>
-   <dt>If <var title="">input</var> is an Object object</dt>
+   </li>
 
-   <dd>
+   <li><p>Add a mapping from <var title="">input</var> (the source
+   object) to <var title="">output</var> (the destination object) to
+   <var title="">memory</var>.</p></li>
 
-    <ol>
+   <li>
 
-     <li><p>If <var title="">input</var> is in <var
-     title="">memory</var>, then throw a <code>DATA_CLONE_ERR</code>
-     exception and abort the overall <span>structured clone</span>
-     algorithm.</p></li>
+    <p>If <var title="">input</var> is an Array object or an Object
+    object, then, for each enumerable property in <var
+    title="">input</var>, add a corresponding property to <var
+    title="">output</var> having the same name, and having a value
+    created from invoking the <span>internal structured cloning
+    algorithm</span> recursively with the value of the property as the
+    "<var title="">input</var>" argument and <var
+    title="">memory</var> as the "<var title="">memory</var>"
+    argument. The order of the properties in the <var
+    title="">input</var> and <var title="">output</var> objects must
+    be the same.</p>
 
-     <li><p>Otherwise, let <var title="">new memory</var> be a list
-     consisting of the items in <var title="">memory</var> with the
-     addition of <var title="">input</var>.</p></li>
+    <p class="note">This does not walk the prototype chain.</p>
 
-     <li><p>Create a new object, <var title="">output</var>, of the
-     same type as <var title="">input</var>: either an Array or an
-     Object.</p></li>
+   </li>
 
-     <li>
+   <li><p>Return <var title="">output</var>.</p></li>
 
-      <p>For each enumerable property in <var title="">input</var>,
-      add a corresponding property to <var title="">output</var>
-      having the same name, and having a value created from invoking
-      the <span>internal structured cloning algorithm</span>
-      recursively with the value of the property as the "<var
-      title="">input</var>" argument and <var title="">new
-      memory</var> as the "<var title="">memory</var>" argument. The
-      order of the properties in the <var title="">input</var> and
-      <var title="">output</var> objects must be the same.</p>
+  </ol>
 
-      <p class="note">This does not walk the prototype chain.</p>
+  <p class="note">This algorithm preserves cycles and preserves the
+  identity of duplicate objects in graphs.</p>
 
-     </li>
-
-     <li><p>Return <var title="">output</var>.</p></li>
-
-    </ol>
-
-   </dd>
-
-   <dt>If <var title="">input</var> is another native object type (e.g. <code>Error</code>, <code>Function</code>)</dt>
-   <dt>If <var title="">input</var> is a host object (e.g. a DOM node)</dt>
-
-   <dd><p>Throw a <code>DATA_CLONE_ERR</code> exception and abort the
-   overall <span>structured clone</span> algorithm.</p></dd>
-
-  </dl>
-
   </div>
 
 




More information about the Commit-Watchers mailing list