Index: Source/WebCore/dom/Node.cpp |
=================================================================== |
--- Source/WebCore/dom/Node.cpp (revision 81450) |
+++ Source/WebCore/dom/Node.cpp (working copy) |
@@ -758,6 +758,13 @@ |
if (this->document() == document || this->inDocument()) |
return; |
+ // If an element is moved from a document and then eventually back again the collection cache for |
+ // that element may contain stale data as changes made to it will have updated the DOMTreeVersion |
+ // of the document it was moved to. By increasing the DOMTreeVersion of the donating document here |
+ // we ensure that the collection cache will be invalidated as needed when the element is moved back. |
+ if (this->document()) |
+ this->document()->incDOMTreeVersion(); |
+ |
for (Node* node = this; node; node = node->traverseNextNode(this)) { |
node->setDocument(document); |
if (!node->isElementNode()) |