Index: third_party/WebKit/Source/core/dom/TreeScopeAdopter.cpp |
diff --git a/third_party/WebKit/Source/core/dom/TreeScopeAdopter.cpp b/third_party/WebKit/Source/core/dom/TreeScopeAdopter.cpp |
index 8600f7773cf3b11aa8b994cf5d819644ce31eddf..bea9098bde06a1012d2d3b9ff18b6ce096669652 100644 |
--- a/third_party/WebKit/Source/core/dom/TreeScopeAdopter.cpp |
+++ b/third_party/WebKit/Source/core/dom/TreeScopeAdopter.cpp |
@@ -128,6 +128,8 @@ inline void TreeScopeAdopter::moveNodeToNewDocument( |
Document& oldDocument, |
Document& newDocument) const { |
DCHECK_NE(oldDocument, newDocument); |
+ // Note: at the start of this function, node.document() may already have |
+ // changed to match |newDocument|, which is why |oldDocument| is passed in. |
if (node.hasRareData()) { |
NodeRareData* rareData = node.rareData(); |
@@ -135,6 +137,7 @@ inline void TreeScopeAdopter::moveNodeToNewDocument( |
rareData->nodeLists()->adoptDocument(oldDocument, newDocument); |
} |
+ node.willMoveToNewDocument(oldDocument, newDocument); |
oldDocument.moveNodeIteratorsToNewDocument(node, newDocument); |
if (node.getCustomElementState() == CustomElementState::Custom) { |