a picture
of something
¯\_(ツ)_/¯
Explanation:
The four normal DOM documents look like this (excluding < style > elements):
1.---------------------------
index.html
...
< portrait-frame >
"¯\_(ツ)_/¯"
...
2.---------------------------
portrait-frame#shadowRoot
< green-frame >
< slot#portraitOne >
"a picture"
< blue-frame >
< slot#portraitTwo name="label" >
"of something"
3.---------------------------
green-frame#shadowRoot
< slot#green >
4.---------------------------
blue-frame#shadowRoot
< slot#blue >
Adding the "matroska
Below is the flattened DOM _before_ "matroska" is added.
...
< portrait-frame >
#shadowRoot
< green-frame >
#shadowRoot
< slot#green >
< slot#portraitOne >
"¯\_(ツ)_/¯"
< blue-frame >
#shadowRoot
< slot#blue >
< slot#portraitTwo >
"of something"
Important to note here is:
-
blue-frame element is _slotted_ into green-frame.
-
slot#portraitTwo is directly chained to slot#blue.
But! slot#portraitTwo is NOT directly chained to slot#green.
-
But since the host element blue-frame is put inside slot#green,
that means that also the blue-frame#shadowRoot and the SlotMatroska
it contains _also_ is contained within green-frame#shadowRoot and slot#green.
When "matroska" is added, this changes the flattened DOM and causes a slotchange event
to be dispatched on slot#portraitTwo:
...
< portrait-frame > _
#shadowRoot *3
< green-frame > |
#shadowRoot *2
< slot#green > |
< slot#portraitOne >
"¯\_(ツ)_/¯"
< blue-frame > |
#shadowRoot *1
< slot#blue > |
< slot#portraitTwo > slotchange ^
< span >
"matroska"
And prints the following three logs:
BLUE-FRAME [slot#portraitTwo, slot#blue, document-fragment, blue-frame, slot#green, document-fragment, green-frame, document-fragment]
GREEN-FRAME [slot#portraitTwo, slot#blue, document-fragment, blue-frame, slot#green, document-fragment, green-frame, document-fragment]
PORTRAIT-FRAME [slot#portraitTwo, slot#blue, document-fragment, blue-frame, slot#green, document-fragment, green-frame, document-fragment]
When this slotchange event bubbles upwards, it passes *all* three #shadowRoot and slot#blue, slot#green, and slot#portraitTwo,
but not slot#portraitOne.