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

Ground custom elements in agents #4204

Merged
merged 5 commits into from
Jan 16, 2019
Merged
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
65 changes: 36 additions & 29 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -67050,12 +67050,12 @@ customElements.define("x-foo", class extends HTMLElement {

<hr>

<p>Each <span>unit of related similar-origin browsing contexts</span> has a <dfn>custom element
reactions stack</dfn>, which is initially empty. The <dfn>current element queue</dfn> is the
<span>element queue</span> at the top of the <span>custom element reactions stack</span>. Each
item in the stack is an <dfn>element queue</dfn>, which is initially empty as well. Each item in
an <span>element queue</span> is an element. (The elements are not necessarily <span
data-x="concept-element-custom">custom</span> yet, since this queue is used for <span
<p>Each <span>similar-origin window agent</span> has a <dfn>custom element reactions stack</dfn>,
annevk marked this conversation as resolved.
Show resolved Hide resolved
which is initially empty. A <span>similar-origin window agent</span>'s <dfn>current element
queue</dfn> is the <span>element queue</span> at the top of its <span>custom element reactions
stack</span>. Each item in the stack is an <dfn>element queue</dfn>, which is initially empty as
well. Each item in an <span>element queue</span> is an element. (The elements are not necessarily
<span data-x="concept-element-custom">custom</span> yet, since this queue is used for <span
data-x="custom-element-upgrades">upgrades</span> as well.)</p>

<p>Each <span>custom element reactions stack</span> has an associated <dfn>backup element
Expand Down Expand Up @@ -67088,31 +67088,38 @@ customElements.define("x-foo", class extends HTMLElement {
<var>element</var>, run the following steps:</p>

<ol>
<li><p>Let <var>reactionsStack</var> be <var>element</var>'s <span>relevant agent</span>'s
annevk marked this conversation as resolved.
Show resolved Hide resolved
<span>custom element reactions stack</span>.</p></li>

<li>
<p>If the <span>custom element reactions stack</span> is empty, then:</p>
<p>If <var>reactionsStack</var> is empty, then:</p>

<ol>
<li><p>Add <var>element</var> to the <span>backup element queue</span>.</p></li>
<li><p>Add <var>element</var> to <var>reactionsStack</var>'s <span>backup element
queue</span>.</p></li>

<li><p>If the <span>processing the backup element queue</span> flag is set, then
return.</p></li>
<li><p>If <var>reactionsStack</var>'s <span>processing the backup element queue</span> flag is
set, then return.</p></li>

<li><p>Set the <span>processing the backup element queue</span> flag.</p></li>
<li><p>Set <var>reactionsStack</var>'s <span>processing the backup element queue</span>
flag.</p></li>

<li>
<p><span>Queue a microtask</span> to perform the following steps:</p>

<ol>
<li><p><span>Invoke custom element reactions</span> in the <span>backup element
queue</span>.</p></li>
<li><p><span>Invoke custom element reactions</span> in <var>reactionsStack</var>'s
<span>backup element queue</span>.</p></li>

<li><p>Unset the <span>processing the backup element queue</span> flag.</p></li>
<li><p>Unset <var>reactionsStack</var>'s <span>processing the backup element queue</span>
flag.</p></li>
</ol>
</li>
</ol>
</li>

<li><p>Otherwise, add <var>element</var> to the <span>current element queue</span>.</p></li>
<li><p>Otherwise, add <var>element</var> to <var>element</var>'s <span>relevant agent</span>'s
<span>current element queue</span>.</p></li>
</ol>

<p>To <dfn data-export="">enqueue a custom element callback reaction</dfn>, given a <span>custom
Expand Down Expand Up @@ -67218,15 +67225,15 @@ customElements.define("x-foo", class extends HTMLElement {
of the ones specified in their description:</p>

<ol>
<li><p><span data-x="stack push">Push</span> a new <span>element queue</span> onto the
<span>custom element reactions stack</span>.</p></li>
<li><p><span data-x="stack push">Push</span> a new <span>element queue</span> onto this object's
<span>relevant agent</span>'s <span>custom element reactions stack</span>.</p></li>

<li><p>Run the originally-specified steps for this construct, catching any exceptions. If the
steps return a value, let <var>value</var> be the returned value. If they throw an exception, let
<var>exception</var> be the thrown exception.</p></li>

<li><p>Let <var>queue</var> be the result of <span data-x="stack pop">popping</span> from the
<span>custom element reactions stack</span>.</p></li>
<li><p>Let <var>queue</var> be the result of <span data-x="stack pop">popping</span> from this
object's <span>relevant agent</span>'s <span>custom element reactions stack</span>.</p></li>

<li><p><span>Invoke custom element reactions</span> in <var>queue</var>.</p></li>

Expand Down Expand Up @@ -105884,8 +105891,8 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
<li><p>If the <span>JavaScript execution context stack</span> is empty, then <span>perform a
microtask checkpoint</span>.</p></li>

<li><p>Push a new <span>element queue</span> onto the <span>custom element reactions
stack</span>.</li>
<li><p>Push a new <span>element queue</span> onto <var>document</var>'s <span>relevant
agent</span>'s <span>custom element reactions stack</span>.</li>
</ol>
</li>

Expand Down Expand Up @@ -105920,9 +105927,9 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
<p>If <var>will execute script</var> is true, then:</p>

<ol>
<li><p>Let <var>queue</var> be the result of popping the <span>current element queue</span>
from the <span>custom element reactions stack</span>. (This will be the same <span>element
queue</span> as was pushed above.)</p></li>
<li><p>Let <var>queue</var> be the result of popping from <var>document</var>'s <span>relevant
agent</span>'s <span>custom element reactions stack</span>. (This will be the same
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't pop the queue. You pop from the stack; the result is === the current queue (at least, the current queue before popping). I think just omit mention of the current queue from here, and use "popping from" like above.

<span>element queue</span> as was pushed above.)</p></li>

<li><p><span>Invoke custom element reactions</span> in <var>queue</var>.</p></li>

Expand Down Expand Up @@ -105982,15 +105989,15 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {

<ol>
<li><p>If the parser was not created as part of the <span>HTML fragment parsing
algorithm</span>, then push a new <span>element queue</span> onto the <span>custom element
reactions stack</span>.</li>
algorithm</span>, then push a new <span>element queue</span> onto <var>element</var>'s
<span>relevant agent</span>'s <span>custom element reactions stack</span>.</li>

<li><p>Insert <var>element</var> at the <var>adjusted insertion location</var>.</p></li>

<li><p>If the parser was not created as part of the <span>HTML fragment parsing
algorithm</span>, then pop the <span>element queue</span> from the <span>custom element
reactions stack</span>, and <span>invoke custom element reactions</span> in that
queue.</p></li>
algorithm</span>, then pop the <span>element queue</span> from <var>element</var>'s
<span>relevant agent</span>'s <span>custom element reactions stack</span>, and <span>invoke
custom element reactions</span> in that queue.</p></li>
</ol>

<p class="note">If the <var>adjusted insertion location</var> cannot accept more
Expand Down