src/language/HTMLDOMDiff.js
function (beforeID, isBeingDeleted) {
            newEdits.forEach(function (edit) {
                // elementDeletes don't need any positioning information
                if (edit.type !== "elementDelete") {
                    edit.beforeID = beforeID;
                }
            });
            edits.push.apply(edits, newEdits);
            newEdits = [];

            // If the item we made this set of edits relative to
            // is being deleted, we can't use it as the afterID for future
            // edits. It's okay to just keep the previous afterID, since
            // this node will no longer be in the tree by the time we get
            // to any future edit that needs an afterID.
            if (!isBeingDeleted) {
                textAfterID = beforeID;
            }
        }
function (beforeID, isBeingDeleted) {
            newEdits.forEach(function (edit) {
                // elementDeletes don't need any positioning information
                if (edit.type !== "elementDelete") {
                    edit.beforeID = beforeID;
                }
            });
            edits.push.apply(edits, newEdits);
            newEdits = [];

            // If the item we made this set of edits relative to
            // is being deleted, we can't use it as the afterID for future
            // edits. It's okay to just keep the previous afterID, since
            // this node will no longer be in the tree by the time we get
            // to any future edit that needs an afterID.
            if (!isBeingDeleted) {
                textAfterID = beforeID;
            }
        }
function ( beforeID , isBeingDeleted ) { newEdits . forEach ( function ( edit ) { // elementDeletes don't need any positioning information if ( edit . type !== "elementDelete" ) { edit . beforeID = beforeID ; } } ) ; edits . push . apply ( edits , newEdits ) ; newEdits = [ ] ; // If the item we made this set of edits relative to // is being deleted, we can't use it as the afterID for future // edits. It's okay to just keep the previous afterID, since // this node will no longer be in the tree by the time we get // to any future edit that needs an afterID. if ( ! isBeingDeleted ) { textAfterID = beforeID ; } }
We initially put new edit objects into the `newEdits` array so that we
can fix them up with proper positioning information. This function is
responsible for doing that fixup.

The `beforeID` that appears in many edits tells the browser to make the
change before the element with the given ID. In other words, an
elementInsert with a `beforeID` of 32 would result in something like
`parentElement.insertBefore(newChildElement, _queryBracketsID(32))`

Many new edits are captured in the `newEdits` array so that a suitable
`beforeID` can be added to them before they are added to the main edits
list. This function sets the `beforeID` on any pending edits and adds
them to the main list.

If this item is not being deleted, then it will be used as the `afterID`
for text edits that follow.

@param {int} beforeID ID to set on the pending edits
@param {boolean} isBeingDeleted true if the given item is being deleted. If so,
we can't use it as the `afterID` for future edits--whatever previous item
was set as the `textAfterID` is still okay.
We initially put new edit objects into the newEdits array so that we can fix them up with proper positioning information . This function is responsible for doing that fixup .