Index: Source/WebCore/dom/ContainerNodeAlgorithms.cpp |
=================================================================== |
--- Source/WebCore/dom/ContainerNodeAlgorithms.cpp (revision 132829) |
+++ Source/WebCore/dom/ContainerNodeAlgorithms.cpp (working copy) |
@@ -48,8 +48,10 @@ |
if (ElementShadow* shadow = toElement(node)->shadow()) { |
ShadowRootVector roots(shadow); |
- for (size_t i = 0; i < roots.size(); ++i) |
- notifyNodeInsertedIntoDocument(roots[i].get()); |
+ for (size_t i = 0; i < roots.size(); ++i) { |
+ if (node->inDocument() && roots[i]->host() == node) |
+ notifyNodeInsertedIntoDocument(roots[i].get()); |
+ } |
} |
} |
@@ -83,8 +85,10 @@ |
if (ElementShadow* shadow = toElement(node)->shadow()) { |
ShadowRootVector roots(shadow); |
- for (size_t i = 0; i < roots.size(); ++i) |
- notifyNodeRemovedFromDocument(roots[i].get()); |
+ for (size_t i = 0; i < roots.size(); ++i) { |
+ if (!node->inDocument() && roots[i]->host() == node) |
+ notifyNodeRemovedFromDocument(roots[i].get()); |
+ } |
} |
} |