From 3742cca7e77c9f109ecefdcaff5c0ff72d240b01 Mon Sep 17 00:00:00 2001 From: "peterv%propagandism.org" Date: Thu, 10 Aug 2006 13:05:00 +0000 Subject: [PATCH] Fix for bug 347523 (nsXBLBinding should use importNode instead of cloneNode). r/sr=sicking. --- content/xbl/src/nsXBLBinding.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/content/xbl/src/nsXBLBinding.cpp b/content/xbl/src/nsXBLBinding.cpp index 063932bd8065..7ee69195dbb7 100644 --- a/content/xbl/src/nsXBLBinding.cpp +++ b/content/xbl/src/nsXBLBinding.cpp @@ -380,11 +380,16 @@ RealizeDefaultContent(nsHashKey* aKey, void* aData, void* aClosure) // We need to take this template and use it to realize the // actual default content (through cloning). // Clone this insertion point element. + nsCOMPtr insParent = currPoint->GetInsertionParent(); + nsCOMPtr document = + do_QueryInterface(insParent->GetOwnerDoc()); + if (!document) { + return NS_ERROR_FAILURE; + } + nsCOMPtr elt(do_QueryInterface(defContent)); nsCOMPtr clonedNode; - elt->CloneNode(PR_TRUE, getter_AddRefs(clonedNode)); - - nsCOMPtr insParent = currPoint->GetInsertionParent(); + document->ImportNode(elt, PR_TRUE, getter_AddRefs(clonedNode)); // Now that we have the cloned content, install the default content as // if it were additional anonymous content. @@ -506,9 +511,15 @@ nsXBLBinding::GenerateAnonymousContent() if (hasContent || hasInsertionPoints) { nsCOMPtr domElement(do_QueryInterface(content)); + nsCOMPtr document = + do_QueryInterface(mBoundElement->GetOwnerDoc()); + if (!document) { + return; + } + nsCOMPtr clonedNode; - domElement->CloneNode(PR_TRUE, getter_AddRefs(clonedNode)); - + document->ImportNode(domElement, PR_TRUE, getter_AddRefs(clonedNode)); + mContent = do_QueryInterface(clonedNode); InstallAnonymousContent(mContent, mBoundElement);