Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State-preserving atomic move integration #10657

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 86 additions & 6 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -1773,8 +1773,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
data-x="control">controls</span> or U+0020 SPACE).</p>

<p>An HTML element can have specific <dfn>HTML element insertion steps</dfn>, <dfn>HTML element
post-connection steps</dfn>, and <dfn>HTML element removing steps</dfn>, all defined for the
element's <span data-x="concept-element-local-name">local name</span>.</p>
post-connection steps</dfn>, <dfn>HTML element removing steps</dfn>, and <dfn>HTML element moving
steps</dfn> all defined for the element's <span data-x="concept-element-local-name">local
name</span>.</p>

<p>The <span data-x="concept-node-insert-ext">insertion steps</span> for the HTML Standard, given
<var>insertedNode</var>, are defined as the following:</p>
Expand Down Expand Up @@ -1861,6 +1862,48 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
popover algorithm</span> given <var>removedNode</var>, false, false, and false.</p></li>
</ol>

<p>The <span data-x="concept-node-move-ext">moving steps</span> for the HTML Standard, given
<var>movedNode</var>, are defined as the following:</p>

<ol>
<li><p>If <var>movedNode</var> is an element whose <span
data-x="concept-element-namespace">namespace</span> is the <span>HTML namespace</span>, and this
standard defines <span>HTML element moving steps</span> for <var>movedNode</var>'s <span
data-x="concept-element-local-name">local name</span>, then run the corresponding <span>HTML
element moving steps</span> given <var>movedNode</var>.</p></li>

<li>
<p>If <var>movedNode</var> is a <span>custom element</span>, then:<p>

<ol>
<li><p>If the element has an author-provided <code data-x="">connectedMoveCallback</code>, then
call it with no arguments.</p></li>

<li>
<p>Otherwise:</p>
<ol>
<li><p>Call <var>movedNode</var>'s <code data-x="">disconnectedCallback</code>, with no
arguments.</p></li>
<li><p>Call <var>movedNode</var>'s <code data-x="">connectedCallback</code>, with no
arguments.</p></li>
</ol>
</li>
</ol>
</li>

<li>
<p>If <var>movedNode</var> is a <span>form-associated element</span> or the ancestor of a
<span>form-associated element</span>, then:</p>

<ol>
<li><p>If the <span>form-associated element</span>'s <span>parser inserted flag</span> is set,
then return.</p></li>

<li><p><span>Reset the form owner</span> of the <span>form-associated element</span>.</p></li>
</ol>
</li>
</ol>

<p>A <dfn id="insert-an-element-into-a-document" data-x="node is inserted into a document"
data-lt="inserted into a document|node is inserted into a document" export>node is inserted into a
document</dfn> when the <span data-x="concept-node-insert-ext">insertion steps</span> are invoked
Expand Down Expand Up @@ -3218,6 +3261,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x="dom-Node-append" data-x-href="https://dom.spec.whatwg.org/#dom-node-append"><code>append()</code></dfn> method</li>
<li><dfn data-x="dom-Node-appendChild" data-x-href="https://dom.spec.whatwg.org/#dom-node-appendchild"><code>appendChild()</code></dfn> method</li>
<li><dfn data-x="dom-Node-cloneNode" data-x-href="https://dom.spec.whatwg.org/#dom-node-clonenode"><code>cloneNode()</code></dfn> method</li>
<li><dfn data-x="dom-Node-moveBefore" data-x-href="https://dom.spec.whatwg.org/#dom-node-moveBefore"><code>moveBefore()</code></dfn> method</li>
<li><dfn data-x="dom-Document-importNode" data-x-href="https://dom.spec.whatwg.org/#dom-document-importnode"><code>importNode()</code></dfn> method</li>
<li><dfn data-x="dom-Event-preventDefault" data-x-href="https://dom.spec.whatwg.org/#dom-event-preventdefault"><code>preventDefault()</code></dfn> method</li>
<li><dfn data-x="dom-Element-id" data-x-href="https://dom.spec.whatwg.org/#dom-element-id"><code>id</code></dfn> attribute</li>
Expand Down Expand Up @@ -3257,6 +3301,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li>The <dfn data-x="concept-node-insert-ext" data-x-href="https://dom.spec.whatwg.org/#concept-node-insert-ext">insertion steps</dfn>,
<li>The <dfn data-x="concept-node-post-insert-ext" data-x-href="https://dom.spec.whatwg.org/#concept-node-post-connection-ext">post-connection steps</dfn>,
<dfn data-x="concept-node-remove-ext" data-x-href="https://dom.spec.whatwg.org/#concept-node-remove-ext">removing steps</dfn>,
<dfn data-x="concept-node-move-ext" data-x-href="https://dom.spec.whatwg.org/#concept-node-move-ext">moving steps</dfn>,
<dfn data-x="concept-node-adopt-ext" data-x-href="https://dom.spec.whatwg.org/#concept-node-adopt-ext">adopting steps</dfn>, and
<dfn data-x-href="https://dom.spec.whatwg.org/#concept-node-children-changed-ext">children changed steps</dfn> hooks for elements</li>
<li>The <dfn data-x="concept-element-attributes-change" data-x-href="https://dom.spec.whatwg.org/#concept-element-attributes-change">change</dfn>, <dfn data-x="concept-element-attributes-append" data-x-href="https://dom.spec.whatwg.org/#concept-element-attributes-append">append</dfn>, <dfn data-x="concept-element-attributes-remove" data-x-href="https://dom.spec.whatwg.org/#concept-element-attributes-remove">remove</dfn>, <dfn data-x="concept-element-attributes-replace" data-x-href="https://dom.spec.whatwg.org/#concept-element-attributes-replace">replace</dfn>, <dfn data-x="concept-element-attributes-get-by-namespace" data-x-href="https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace">get an attribute by namespace and local name</dfn>, <dfn data-x="concept-element-attributes-set-value" data-x-href="https://dom.spec.whatwg.org/#concept-element-attributes-set-value">set value</dfn>, and <dfn data-x="concept-element-attributes-remove-by-namespace" data-x-href="https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace">remove an attribute by namespace and local name</dfn> algorithms for attributes</li>
Expand Down Expand Up @@ -10820,6 +10865,20 @@ partial interface <dfn id="document" data-lt="">Document</dfn> {
<span>set</span> of <span data-x="nrr-details-struct">not restored reason details</span>,
initially empty.</p>

<p>Each <code>Document</code> has a <dfn
data-x="concept-document-state-preserving-atomic-move-in-progress" export
for="Document">state-preserving atomic move in progress</dfn> boolean, which is initially
false.</p>

<p class="note">This is set by <code data-x="dom-Node-moveBefore">moveBefore()</code> when a
<code>Document</code> is performing a state-preserving atomic move; it is used to exempt certain
<span data-x="concept-node-insert-ext">insertion steps</span> and <span
data-x="concept-node-remove-ext">removing steps</span> (and their kin), from running, if they
would ordinarily reset state that needs to be preserved.</p>

<p class=XXX>TODO(domfarolino): Before merging, probably remove this flag since we're going with
the HTML element moving steps infrastructure instead.</p>

<h4>The <code>DocumentOrShadowRoot</code> interface</h4>

<p><cite>DOM</cite> defines the <code data-x="DOM
Expand Down Expand Up @@ -36418,13 +36477,15 @@ interface <dfn interface>MediaError</dfn> {
other node is the node after <var>pointer</var>. Initially, let <var>pointer</var> be the position between the <var>candidate</var> node and the
next node, if there are any, or the end of the list, if it is the last node.</p>

<p>As nodes are <span data-x="concept-node-insert-ext">inserted</span> and <span
data-x="concept-node-remove-ext">removed</span> into the <span>media element</span>,
<p>As nodes are <span data-x="concept-node-insert-ext">inserted</span>, <span
data-x="concept-node-remove-ext">removed</span>, and <span
data-x="concept-node-move-ext">moved</span> into the <span>media element</span>,
<var>pointer</var> must be updated as follows:</p>

<dl>
<dt>If a new node is <span data-x="concept-node-insert-ext">inserted</span> between the two
nodes that define <var>pointer</var></dt>
<dt>If a new node is <span data-x="concept-node-insert-ext">inserted</span> or <span
data-x="concept-node-move-ext">moved</span> between the two nodes that define
<var>pointer</var></dt>

<dd>Let <var>pointer</var> be the point between the node before <var>pointer</var> and the new node. In other words, insertions at <var>pointer</var> go after <var>pointer</var>.</dd>

Expand Down Expand Up @@ -53462,6 +53523,17 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
<code>select</code> element's <span>selectedness setting algorithm</span>.</p></li>
</ol>

<p>The <code>option</code> <span>HTML element moving steps</span>, given <var>movedNode</var> and
<var>oldParent</var>, are:</p>

<ol>
<li><p>Run the <code>option</code> <span>HTML element removing steps</span> given
<var>movedNode</var> and <var>oldParent</var>.</p></li>

<li><p>Run the <code>option</code> <span>HTML element insertion steps</span> given
<var>movedNode</var>.</p></li>
</ol>

<p>The <code>optgroup</code> <span data-x="html element removing steps">HTML element removing
steps</span>, given <var>removedNode</var> and <var>oldParent</var>, are:</p>

Expand All @@ -53471,6 +53543,14 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
algorithm</span>.</p></li>
</ol>

<p>The <code>optgroup</code> <span>HTML element moving steps</span>, given <var>movedNode</var>
and <var>oldParent</var>, are:</p>

<ol>
<li><p>Run the <code>optgroup</code> <span>HTML element removing steps</span> given
<var>movedNode</var> and <var>oldParent</var>.</p></li>
</ol>

<p>If an <code>option</code> element in the <span data-x="concept-select-option-list">list of
options</span> <dfn data-x="ask for a reset">asks for a reset</dfn>, then run that
<code>select</code> element's <span>selectedness setting algorithm</span>.</p>
Expand Down