Skip to content

Commit

Permalink
Ground custom elements in agents
Browse files Browse the repository at this point in the history
The "unit of related similar-origin browsing contexts" concept is inaccurate.

Helps with #4198.
  • Loading branch information
annevk authored and domenic committed Jan 16, 2019
1 parent 90d5f45 commit bb93fad
Showing 1 changed file with 36 additions and 29 deletions.
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>,
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
<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 @@ -105883,8 +105890,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 @@ -105919,9 +105926,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
<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 @@ -105981,15 +105988,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

0 comments on commit bb93fad

Please sign in to comment.