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

NEW
Unassigned

Status

()

P5
normal
4 years ago
5 months ago

People

(Reporter: heycam, Unassigned)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

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://bugzilla.mozilla.org/show_bug.cgi?id=1472046

Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.