diff --git a/content/xbl/src/nsXBLBinding.cpp b/content/xbl/src/nsXBLBinding.cpp index 356dfdc4b171..6576781ca269 100644 --- a/content/xbl/src/nsXBLBinding.cpp +++ b/content/xbl/src/nsXBLBinding.cpp @@ -725,6 +725,21 @@ nsXBLBinding::GenerateAnonymousContent() if (ni->NamespaceID() != kNameSpaceID_XUL || (localName != nsGkAtoms::observes && localName != nsGkAtoms::_template)) { + // Undo InstallAnonymousContent + PRUint32 childCount = mContent->GetChildCount(); +#ifdef MOZ_XUL + nsCOMPtr xuldoc(do_QueryInterface(doc)); +#endif + for (PRUint32 k = 0; k < childCount; ++k) { + nsIContent* child = mContent->GetChildAt(k); + child->UnbindFromTree(); +#ifdef MOZ_XUL + if (xuldoc) { + xuldoc->RemoveSubtreeFromDocument(child); + } +#endif + } + // Kill all anonymous content. mContent = nsnull; bindingManager->SetContentListFor(mBoundElement, nsnull);