Bug 1484040, unbind shadow DOM content when uninstalling shadow DOM based XML Pretty Printer, r=timdream

This commit is contained in:
Olli Pettay 2018-08-17 02:49:16 +03:00
parent e50444f450
commit 9ea97a4cf5

View File

@ -1275,7 +1275,8 @@ Element::AttachShadowWithoutNameChecks(ShadowRootMode aMode)
void
Element::UnattachShadow()
{
if (!GetShadowRoot()) {
RefPtr<ShadowRoot> shadowRoot = GetShadowRoot();
if (!shadowRoot) {
return;
}
@ -1290,6 +1291,12 @@ Element::UnattachShadow()
// Simply unhook the shadow root from the element.
MOZ_ASSERT(!GetShadowRoot()->HasSlots(), "Won't work when shadow root has slots!");
for (nsIContent* child = shadowRoot->GetFirstChild(); child;
child = child->GetNextSibling()) {
child->UnbindFromTree(true, false);
}
shadowRoot->SetIsComposedDocParticipant(false);
SetShadowRoot(nullptr);
}