SlotchangeNipSlip #3: CreateRedundantSlotchangeEvents
We start viewing the situation from HTML.
-
A h2 and span element are declared in the top most lightDOM.
-
The h2 and span elements are then transposed into their respective slot element in the portrait-frame shadowDOM.
-
Then, the two slot elements in the portrait-frame shadowDOM are transposed into two different green-frame elements
and their inner slots.
-
From the perspective of HTML, this should trigger a total of four slotchange events.
But, in JS, four(?!) slotchange events are triggered.
-
frameOne (2) [slot, document-fragment]
This event is triggered as the first slot in portrait-frame is transposed to the inner slot in the first green-frame
element.
-
frameTwo (2) [slot, document-fragment]
This event is triggered as the first slot in portrait-frame is transposed to the inner slot in the first green-frame
element.
-
frameOne (5) [slot, slot, document-fragment, green-frame#frameOne, document-fragment]
portrait (5) [slot, slot, document-fragment, green-frame#frameOne, document-fragment]
"¯\_(ツ)_/¯" is added to the portrait-frame element. This element is then transposed to the portrait-frame element
and then the green-frame#one. The green-frame#one slotchange event listener is triggered first, then the portrait.
-
frameTwo (5) [slot, slot, document-fragment, green-frame#frameTwo, document-fragment]
portrait (5) [slot, slot, document-fragment, green-frame#frameTwo, document-fragment]
"self-portrait, by ivar" is added to the portrait-frame element. This element is then transposed to the
portrait-frame element and then the green-frame#two. The inner, green-frame#two slotchange event listener is
triggered first, then the outer portrait-frame event listener.