From bb93fad504dd5012fe480ce3894c1ad9a43ce53a Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Wed, 16 Jan 2019 17:19:20 +0100 Subject: [PATCH] Ground custom elements in agents The "unit of related similar-origin browsing contexts" concept is inaccurate. Helps with #4198. --- source | 65 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/source b/source index b9d73632623..4a5c116dce3 100644 --- a/source +++ b/source @@ -67050,12 +67050,12 @@ 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 custom yet, since this queue is used for Each similar-origin window agent has a custom element reactions stack, + which is initially empty. A similar-origin window agent's current element + queue is the element queue at the top of its 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.)

Each custom element reactions stack has an associated backup element @@ -67088,31 +67088,38 @@ customElements.define("x-foo", class extends HTMLElement { element, run the following steps:

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

  2. +
  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 element's relevant agent's + current element queue.

To enqueue a custom element callback reaction, given a custom @@ -67218,15 +67225,15 @@ 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. Push a new element queue onto this object's + relevant agent's custom element reactions stack.

  4. 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.

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

  7. +
  8. Let queue be the result of popping from this + object's relevant agent's custom element reactions stack.

  9. Invoke custom element reactions in queue.

  10. @@ -105883,8 +105890,8 @@ dictionary StorageEventInit : EventInit {
  11. If the JavaScript execution context stack is empty, then perform a microtask checkpoint.

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

  14. +
  15. Push a new element queue onto document's relevant + agent's custom element reactions stack.

@@ -105919,9 +105926,9 @@ 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 from document's relevant + agent's custom element reactions stack. (This will be the same + element queue as was pushed above.)

  4. Invoke custom element reactions in queue.

  5. @@ -105981,15 +105988,15 @@ dictionary StorageEventInit : EventInit {
    1. If the parser was not created as part of the HTML fragment parsing - algorithm, then push a new element queue onto the custom element - reactions stack.

    2. + algorithm, then push a new element queue onto element's + relevant agent's custom element reactions stack.
    3. Insert element at the adjusted insertion location.

    4. If the parser was not created as part of the HTML fragment parsing - algorithm, then pop the element queue from the custom element - reactions stack, and invoke custom element reactions in that - queue.

    5. + algorithm, then pop the element queue from element's + relevant agent's custom element reactions stack, and invoke + custom element reactions in that queue.

    If the adjusted insertion location cannot accept more