From d72b612cae94c1e15c836f435a873cab896a3b80 Mon Sep 17 00:00:00 2001 From: xyin96 Date: Tue, 24 Feb 2015 19:08:22 -0500 Subject: [PATCH] for #10634 --- src/language/HTMLDOMDiff.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/language/HTMLDOMDiff.js b/src/language/HTMLDOMDiff.js index 58de1fdca76..9a0d3840679 100644 --- a/src/language/HTMLDOMDiff.js +++ b/src/language/HTMLDOMDiff.js @@ -570,10 +570,13 @@ define(function (require, exports, module) { // Start at the root of the current tree. queue.push(newNode); + var rootElemChanged = false, deltaID; + do { newElement = queue.pop(); oldElement = oldNodeMap[newElement.tagID]; + // Do we need to compare elements? if (oldElement) { @@ -601,7 +604,7 @@ define(function (require, exports, module) { // because it isn't the child of any other node. The browser-side code doesn't // care about parentage/positioning in this case, and will handle just setting the // ID on the existing implied HTML tag in the browser without actually creating it. - if (!newElement.parent) { + if (!newElement.parent ) { edits.push({ type: "elementInsert", tag: newElement.tag, @@ -609,9 +612,22 @@ define(function (require, exports, module) { parentID: null, attributes: newElement.attributes }); + + + } + + // Since the root tag has a new tag ID if the user copies and pastes the entire document, + // This checks if there is an old node, and if there is, passes that node as a parameter to + // generateChildEdits instead of null. + if (Object.keys(oldNodeMap).length > 0){ + addEdits(generateChildEdits(oldNodeMap[Object.keys(oldNodeMap)[0]], oldNodeMap, newElement, newNodeMap)); + } else { + addEdits(generateChildEdits(null, oldNodeMap, newElement, newNodeMap)); } - addEdits(generateChildEdits(null, oldNodeMap, newElement, newNodeMap)); + + + } } while (queue.length);