From 03f25f453d06ffb63a681535246c28e51d0018bf Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Wed, 24 Aug 2016 02:32:24 -0400 Subject: [PATCH] Process custom element connectedCallback immediately during parsing Fixes https://github.com/w3c/webcomponents/issues/551 by ensuring that insertions into the DOM trigger connectedCallback immediately, instead of putting the callback reaction on the the backup element queue and letting it get triggered at the next microtask checkpoint. This means connectedCallback will generally be invoked when the element has zero children, as expected, instead of a random number depending on when the next custom element is seen. --- source | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/source b/source index f59a3301165..fcd8b3733ff 100644 --- a/source +++ b/source @@ -103585,31 +103585,39 @@ dictionary StorageEventInit : EventInit { in a given namespace, the user agent must run these steps:

    -
  1. Let the adjusted insertion location be the appropriate place for inserting a node.

  2. -
  3. Create an element for the token in the given namespace, with the intended + + +

  4. Let element be the result of creating an element for the token in the given namespace, with the intended parent being the element in which the adjusted insertion location finds itself.

  5. +

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

      If it is possible to insert an element at the adjusted insertion - location, then insert the newly created element at the adjusted insertion - location.

      +
    3. Insert element at the adjusted insertion location.

    4. -

      If the adjusted insertion location cannot accept more - elements, e.g. because it's a Document that already has an element child, then the - newly created element is dropped on the floor.

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

    6. +
    +

    If the adjusted insertion location cannot accept more + elements, e.g. because it's a Document that already has an element child, then + element is dropped on the floor.

  6. -
  7. Push the element onto the stack of open elements so that it is the new +

  8. Push element onto the stack of open elements so that it is the new current node.

  9. -
  10. Return the newly created element.

  11. - +
  12. Return element.

When the steps below require the user agent to insert an HTML element for a token,