diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 8f33cd7124c..a78d6d1185f 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -2374,6 +2374,11 @@ nsDocument::ContentAppended(nsIDocument* aDocument, { NS_ASSERTION(aDocument == this, "unexpected doc"); + if (aContainer->GetBindingParent()) { + // Anonymous node; bail out + return; + } + for (nsINode::ChildIterator iter(aContainer, aNewIndexInContainer); !iter.IsDone(); iter.Next()) { @@ -2391,6 +2396,11 @@ nsDocument::ContentInserted(nsIDocument* aDocument, NS_ABORT_IF_FALSE(aContent, "Null content!"); + if (aContent->GetBindingParent()) { + // Anonymous node; bail out + return; + } + RegisterNamedItems(aContent); } @@ -2404,6 +2414,11 @@ nsDocument::ContentRemoved(nsIDocument* aDocument, NS_ABORT_IF_FALSE(aChild, "Null content!"); + if (aChild->GetBindingParent()) { + // Anonymous node; bail out + return; + } + UnregisterNamedItems(aChild); } @@ -2415,6 +2430,11 @@ nsDocument::AttributeWillChange(nsIDocument* aDocument, NS_ABORT_IF_FALSE(aContent, "Null content!"); NS_PRECONDITION(aAttribute, "Must have an attribute that's changing!"); + if (aContent->GetBindingParent()) { + // Anonymous node; bail out + return; + } + if (aNameSpaceID != kNameSpaceID_None) return; if (aAttribute == nsGkAtoms::name) { @@ -2435,6 +2455,11 @@ nsDocument::AttributeChanged(nsIDocument* aDocument, NS_ABORT_IF_FALSE(aContent, "Null content!"); NS_PRECONDITION(aAttribute, "Must have an attribute that's changing!"); + if (aContent->GetBindingParent()) { + // Anonymous node; bail out + return; + } + if (aNameSpaceID != kNameSpaceID_None) return; if (aAttribute == nsGkAtoms::name) { diff --git a/content/base/test/Makefile.in b/content/base/test/Makefile.in index 1316dcfd404..ab54f6c130e 100644 --- a/content/base/test/Makefile.in +++ b/content/base/test/Makefile.in @@ -314,6 +314,7 @@ _TEST_FILES = test_bug5141.html \ bug466409-empty.css \ test_bug466409.html \ test_classList.html \ + test_bug489925.xhtml \ $(NULL) # Disabled; see bug 492181 # test_plugin_freezing.html diff --git a/content/base/test/test_bug489925.xhtml b/content/base/test/test_bug489925.xhtml new file mode 100644 index 00000000000..b16df3bc7fc --- /dev/null +++ b/content/base/test/test_bug489925.xhtml @@ -0,0 +1,87 @@ + + + + Test for Bug 489925 + + + + + + + + + + + + + + document.getAnonymousElementByAttribute(this, "anonid", "test").id = "test1"; + + + + + + + + + + + + + var s = document.createElement("span"); + s.id = "test2"; + document.getAnonymousElementByAttribute(this, "anonid", "test").appendChild(s); + + + + + + + + + + + + + var s = document.createElement("span"); + s.id = "test3"; + var p = document.getAnonymousElementByAttribute(this, "anonid", "test"); + p.appendChild(document.createTextNode("testing")); + p.insertBefore(s, p.lastChild); + + + + + + +Mozilla Bug 489925 +

+ + + +

+ +
+
+
+ +