src/language/HTMLDOMDiff.js
function () {
            if (!oldNodeMap[newChild.tagID]) {
                newEdit = {
                    type: "elementInsert",
                    tag: newChild.tag,
                    tagID: newChild.tagID,
                    parentID: newChild.parent.tagID,
                    attributes: newChild.attributes
                };

                newEdits.push(newEdit);

                // This newly inserted node needs to have edits generated for its
                // children, so we add it to the queue.
                newElements.push(newChild);

                // A textInsert edit that follows this elementInsert should use
                // this element's ID.
                textAfterID = newChild.tagID;

                // new element means we need to move on to compare the next
                // of the current tree with the one from the old tree that we
                // just compared
                newIndex++;
                return true;
            }
            return false;
        }
function () {
            if (!oldNodeMap[newChild.tagID]) {
                newEdit = {
                    type: "elementInsert",
                    tag: newChild.tag,
                    tagID: newChild.tagID,
                    parentID: newChild.parent.tagID,
                    attributes: newChild.attributes
                };

                newEdits.push(newEdit);

                // This newly inserted node needs to have edits generated for its
                // children, so we add it to the queue.
                newElements.push(newChild);

                // A textInsert edit that follows this elementInsert should use
                // this element's ID.
                textAfterID = newChild.tagID;

                // new element means we need to move on to compare the next
                // of the current tree with the one from the old tree that we
                // just compared
                newIndex++;
                return true;
            }
            return false;
        }
function ( ) { if ( ! oldNodeMap [ newChild . tagID ] ) { newEdit = { type : "elementInsert" , tag : newChild . tag , tagID : newChild . tagID , parentID : newChild . parent . tagID , attributes : newChild . attributes } ; newEdits . push ( newEdit ) ; // This newly inserted node needs to have edits generated for its // children, so we add it to the queue. newElements . push ( newChild ) ; // A textInsert edit that follows this elementInsert should use // this element's ID. textAfterID = newChild . tagID ; // new element means we need to move on to compare the next // of the current tree with the one from the old tree that we // just compared newIndex ++ ; return true ; } return false ; }
If the current element was not in the old DOM, then we will create
an elementInsert edit for it.

If the element was in the old DOM, this will return false and the
main loop will either spot this element later in the child list
or the element has been moved.

@return {boolean} true if an elementInsert was created
If the current element was not in the old DOM then we will create an elementInsert edit for it .