If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Element.createShadowTree does not update style sheets in the old ShadowRoot

NEW
Unassigned

Status

()

Core
DOM
3 years ago
3 years ago

People

(Reporter: heycam, Unassigned)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

3 years ago
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.
(Reporter)

Comment 1

3 years ago
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.
(Reporter)

Comment 2

3 years ago
(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....
(Reporter)

Comment 4

3 years ago
https://tbpl.mozilla.org/?tree=Try&rev=7f8fb00fc9c3 with those two changes.
(Reporter)

Comment 5

3 years ago
Raised https://github.com/w3c/web-platform-tests/issues/1415 for the failing WPT.
You need to log in before you can comment on or make changes to this bug.