Skip to content

Commit

Permalink
Use EnumerableOwnPropertyNames in structured serialization
Browse files Browse the repository at this point in the history
Closes #5374.
  • Loading branch information
AjayPoshak authored Apr 6, 2020
1 parent d160aea commit c4beb9b
Showing 1 changed file with 12 additions and 42 deletions.
54 changes: 12 additions & 42 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2877,7 +2877,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-createbytedatablock">CreateByteDataBlock</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-createdataproperty">CreateDataProperty</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-detacharraybuffer">DetachArrayBuffer</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-enumerableownproperties">EnumerableOwnProperties</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-enumerableownpropertynames">EnumerableOwnPropertyNames</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-finishdynamicimport">FinishDynamicImport</dfn> abstract operation</li>
<li>The <dfn data-x="js-OrdinaryFunctionCreate" data-x-href="https://tc39.es/ecma262/#sec-ordinaryfunctioncreate">OrdinaryFunctionCreate</dfn> abstract operation</li>
<li>The <dfn data-x="js-Get" data-x-href="https://tc39.es/ecma262/#sec-get-o-p">Get</dfn> abstract operation</li>
Expand Down Expand Up @@ -8210,57 +8210,26 @@ interface <dfn>DOMStringList</dfn> {
</li>

<li>
<p>Otherwise:
<p>Otherwise, for each <var>key</var> in !
<span>EnumerableOwnPropertyNames</span>(<var>value</var>, <var>key</var>):</p>

<ol>
<li><p>Let <var>enumerableKeys</var> be a new empty <span data-x="js-List">List</span>.</p></li>

<li>
<p>For each <var>key</var> in ! <var>value</var>.[[OwnPropertyKeys]]():</p>

<ol>
<li>
<p>If <span data-x="js-Type">Type</span>(<var>key</var>) is String, then:</p>

<ol>
<li><p>Let <var>valueDesc</var> be !
<var>value</var>.[[GetOwnProperty]](<var>key</var>).</p></li>

<li><p>If <var>valueDesc</var>.[[Enumerable]] is true, then <span data-x="list
append">append</span> <var>key</var> to <var>enumerableKeys</var>.</p></li>
</ol>
</li>
</ol>
</li>

<li>
<p>For each <var>key</var> in <var>enumerableKeys</var>:</p>
<p>If ! <span>HasOwnProperty</span>(<var>value</var>, <var>key</var>) is true, then:</p>

<ol>
<li>
<p>If ! <span>HasOwnProperty</span>(<var>value</var>, <var>key</var>) is true, then:</p>

<ol>
<li><p>Let <var>inputValue</var> be ? <var>value</var>.[[Get]](<var>key</var>,
<var>value</var>).</p></li>
<li><p>Let <var>inputValue</var> be ? <var>value</var>.[[Get]](<var>key</var>,
<var>value</var>).</p></li>

<li><p>Let <var>outputValue</var> be ?
<span>StructuredSerializeInternal</span>(<var>inputValue</var>, <var>forStorage</var>,
<var>memory</var>).</p></li>
<li><p>Let <var>outputValue</var> be ?
<span>StructuredSerializeInternal</span>(<var>inputValue</var>, <var>forStorage</var>,
<var>memory</var>).</p></li>

<li><p><span data-x="list append">Append</span> { [[Key]]: <var>key</var>, [[Value]]:
<var>outputValue</var> } to <var>serialized</var>.[[Properties]].</p></li>
</ol>
</li>
<li><p><span data-x="list append">Append</span> { [[Key]]: <var>key</var>, [[Value]]:
<var>outputValue</var> } to <var>serialized</var>.[[Properties]].</p></li>
</ol>
</li>
</ol>

<p class="note">The key collection performed above is very similar to the JavaScript
specification's <span>EnumerableOwnProperties</span> operation, but crucially it uses the
deterministic ordering provided by the [[OwnPropertyKeys]] internal method, instead of
reordering the keys in an unspecified manner as <span>EnumerableOwnProperties</span> does.
<ref spec=JAVASCRIPT></p>
</li>
</ol>
</li>
Expand Down Expand Up @@ -120882,6 +120851,7 @@ INSERT INTERFACES HERE
Agust&iacute;n Fern&aacute;ndez,
Aharon (Vladimir) Lanin,
Ajai Tirumali,
Ajay Poshak, <!-- ajayposhak on GitHub -->
Akatsuki Kitamura,
Alan Plum,
Alastair Campbell,
Expand Down

0 comments on commit c4beb9b

Please sign in to comment.