Refactor transplate to keep original DOM
yet another web application frontend development toolkit
Brought to you by:
tchibo
Never remove Node objects from the DOM which the input is read into. Nor do replace such. It removes the source location info. Instead, create an "input DOM" where the source is parsed and kept, iterate the inner/outer cursors on the nodes of it like before, but copy clones from the input DOM into a new document fragment "output" instead of leaving them in place. And instead of replacement, copy over a modified element. Instead of removal, just do not copy anything to the output document.
Diff: