From ec8864a605c84bf3bd84bdc9b0bb581f3acb2c3d Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Mon, 26 Nov 2018 16:34:06 +0100 Subject: [PATCH] Ground custom elements in agents The "unit of related similar-origin browsing contexts" concept is inaccurate. Helps with https://github.com/whatwg/html/issues/4198. --- source | 72 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/source b/source index 0013373ee26..cfe68c2d496 100644 --- a/source +++ b/source @@ -66948,11 +66948,11 @@ customElements.define("x-foo", class extends HTMLElement {
-

Each unit of related similar-origin browsing contexts has a custom element - reactions stack, which is initially empty. The current element queue is the - element queue at the top of the custom element reactions stack. Each - item in the stack is an element queue, which is initially empty as well. Each item in - an element queue is an element. (The elements are not necessarily Each similar-origin window agent has a custom element reactions stack, + which is initially empty. The current element queue is the element queue + at the top of the custom element reactions stack. Each item in the stack is an + element queue, which is initially empty as well. Each item in an element + queue is an element. (The elements are not necessarily custom yet, since this queue is used for upgrades as well.)

@@ -66986,31 +66986,41 @@ customElements.define("x-foo", class extends HTMLElement { element, run the following steps:

    +
  1. Let agent be the similar-origin window agent element's + relevant Realm belongs to. + +

  2. Let reactionsStack be agent's custom element reactions + stack. +

  3. -

    If the custom element reactions stack is empty, then:

    +

    If reactionsStack is empty, then:

      -
    1. Add element to the backup element queue.

    2. +
    3. Add element to reactionsStack's backup element + queue.

    4. -
    5. If the processing the backup element queue flag is set, then - return.

    6. +
    7. If reactionsStack's processing the backup element queue flag is + set, then return.

    8. -
    9. Set the processing the backup element queue flag.

    10. +
    11. Set reactionsStack's processing the backup element queue + flag.

    12. Queue a microtask to perform the following steps:

        -
      1. Invoke custom element reactions in the backup element - queue.

      2. +
      3. Invoke custom element reactions in reactionsStack's + backup element queue.

      4. -
      5. Unset the processing the backup element queue flag.

      6. +
      7. Unset reactionsStack's processing the backup element queue + flag.

  4. -
  5. Otherwise, add element to the current element queue.

  6. +
  7. Otherwise, add element to agent's current element + queue.

To enqueue a custom element callback reaction, given a custom @@ -67116,15 +67126,18 @@ customElements.define("x-foo", class extends HTMLElement { of the ones specified in their description:

    -
  1. Push a new element queue onto the - custom element reactions stack.

  2. +
  3. Let agent be the similar-origin window agent this object's + relevant Realm belongs to. + +

  4. Push a new element queue onto + agent's custom element reactions stack.

  5. Run the originally-specified steps for this construct, catching any exceptions. If the steps return a value, let value be the returned value. If they throw an exception, let exception be the thrown exception.

  6. -
  7. Let queue be the result of popping from the - custom element reactions stack.

  8. +
  9. Let queue be the result of popping from + agent's custom element reactions stack.

  10. Invoke custom element reactions in queue.

  11. @@ -105655,6 +105668,9 @@ dictionary StorageEventInit : EventInit {
    1. Let document be intended parent's node document.

    2. +
    3. Let agent be the similar-origin window agent document's + relevant Realm belongs to. +

    4. Let local name be the tag name of the token.

    5. Let is be the value of the "is" attribute in the @@ -105678,8 +105694,8 @@ dictionary StorageEventInit : EventInit {

    6. If the JavaScript execution context stack is empty, then perform a microtask checkpoint.

    7. -
    8. Push a new element queue onto the custom element reactions - stack.

    9. +
    10. Push a new element queue onto agent's custom element + reactions stack.

    @@ -105714,9 +105730,8 @@ dictionary StorageEventInit : EventInit {

    If will execute script is true, then:

      -
    1. Let queue be the result of popping the current element queue - from the custom element reactions stack. (This will be the same element - queue as was pushed above.)

    2. +
    3. Let queue be the result of popping agent's current element + queue. (This will be the same element queue as was pushed above.)

    4. Invoke custom element reactions in queue.

    5. @@ -105770,18 +105785,21 @@ dictionary StorageEventInit : EventInit { parent being the element in which the adjusted insertion location finds itself.

      +
    6. Let agent be the similar-origin window agent element's + relevant Realm belongs to. +

    7. If it is possible to insert element at the adjusted insertion location, then:

        -
      1. Push a new element queue onto the custom element reactions - stack.

      2. +
      3. Push a new element queue onto agent's custom element + reactions stack.

      4. Insert element at the adjusted insertion location.

      5. -
      6. Pop the element queue from the custom element reactions stack, - and invoke custom element reactions in that queue.

      7. +
      8. Pop the element queue from agent's custom element + reactions stack and invoke custom element reactions in that queue.

      If the adjusted insertion location cannot accept more