Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
xyin96 authored and humphd committed May 20, 2015
1 parent 27b5f98 commit e7b1551
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/language/HTMLDOMDiff.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -601,17 +604,30 @@ 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,
tagID: newElement.tagID,
parentID: null,
attributes: newElement.attributes
});


}

// Since the root <html> tag has a new tag ID if the user copies and pastes the entire document,
// This checks if there is an old <root> 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);

Expand Down

0 comments on commit e7b1551

Please sign in to comment.