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 committed Nov 26, 2018
1 parent 5134310 commit ec8864a
Showing 1 changed file with 45 additions and 27 deletions.
72 changes: 45 additions & 27 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -66948,11 +66948,11 @@ 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
<p>Each <span>similar-origin window agent</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
data-x="custom-element-upgrades">upgrades</span> as well.)</p>

Expand Down Expand Up @@ -66986,31 +66986,41 @@ customElements.define("x-foo", class extends HTMLElement {
<var>element</var>, run the following steps:</p>

<ol>
<li><p>Let <var>agent</var> be the <span>similar-origin window agent</span> <var>element</var>'s
<span>relevant Realm</span> belongs to.

<li><p>Let <var>reactionsStack</var> be <var>agent</var>'s <span>custom element reactions
stack</span>.

<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>agent</var>'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 @@ -67116,15 +67126,18 @@ 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>Let <var>agent</var> be the <span>similar-origin window agent</span> this object's
<span>relevant Realm</span> belongs to.

<li><p><span data-x="stack push">Push</span> a new <span>element queue</span> onto
<var>agent</var>'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
<var>agent</var>'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 @@ -105655,6 +105668,9 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
<ol>
<li><p>Let <var>document</var> be <var>intended parent</var>'s <span>node document</span>.</li>

<li><p>Let <var>agent</var> be the <span>similar-origin window agent</span> <var>document</var>'s
<span>relevant Realm</span> belongs to.

<li><p>Let <var>local name</var> be the tag name of the token.</p></li>

<li><p>Let <var>is</var> be the value of the "<code data-x="attr-is">is</code>" attribute in the
Expand All @@ -105678,8 +105694,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>agent</var>'s <span>custom element
reactions stack</span>.</li>
</ol>
</li>

Expand Down Expand Up @@ -105714,9 +105730,8 @@ 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 <var>agent</var>'s <span>current element
queue</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 @@ -105770,18 +105785,21 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
parent being the element in which the <var>adjusted insertion location</var> finds
itself.</p></li>

<li><p>Let <var>agent</var> be the <span>similar-origin window agent</span> <var>element</var>'s
<span>relevant Realm</span> belongs to.

<li>
<p>If it is possible to insert <var>element</var> at the <var>adjusted insertion location</var>,
then:</p>

<ol>
<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>agent</var>'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>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>
<li><p>Pop the <span>element queue</span> from <var>agent</var>'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 ec8864a

Please sign in to comment.