CSS Scoping says
The descendants of a shadow host must not generate boxes in the formatting tree. Instead, the contents of the active shadow tree generate boxes as if they were the contents of the element instead.
CSS Pseudo-Elements describes ::before and ::after as
these pseudo-elements generate boxes as if they were immediate children of their originating element
So which of these is true?
- First, all the contents of the shadow host (not including
::beforeand::after) are replaced by the contents of the active shadow tree. And then,::beforeand::aftergenerate boxes in the shadow host. - First,
::beforeand::aftergenerate boxes in the shadow host. And then, all the contents of the shadow host (including::beforeand::after) are replaced by the contents of the active shadow tree.
Firefox and Chrome do the former, but does the spec describe the behavior?
var root = document.querySelector('div').createShadowRoot();
root.innerHTML = "<p>Shadow content</p>";
div::before, div::after {
content: 'Generated content';
}
<div>Content</div>