Created attachment 8528618 [details] test Consider the attached test. It should display "1 0 1", according to bug 1098270 comment 19. I think we try to make the second number "0", by unbinding the contents of a ShadowRoot when we create a new, younger ShadowRoot for the host element, but we don't end up calling UpdateStyleSheet on <style> elements we unbind.
In Element::CreateShadowRoot, we first set the newly ShadowRoot on the host element, and then we call UnbindFromTree on the children of the older ShadowRoot. In HTMLStyleElement::UnbindFromTree, GetComposedDoc() returns null (because the <style> element now indeed isn't in the composed document) and we exit early without calling UpdateStyleSheetInternal. I wonder if we can just remove that check and early exit in HTMLStyleElement::UnbindFromTree.
(In reply to Cameron McCormack (:heycam) from comment #1) > I wonder if we can just remove that check and early exit in > HTMLStyleElement::UnbindFromTree. This plus the changes mentioned in bug 1098270 to use GetComposedDoc() in nsStyleLinkElement::DoUpdateStyleSheet seems to work.
Yes, the combination of those would make sense to me. But again, it would be good to have a clear idea of what behavior the spec wants here....
https://tbpl.mozilla.org/?tree=Try&rev=7f8fb00fc9c3 with those two changes.
Raised https://github.com/w3c/web-platform-tests/issues/1415 for the failing WPT.