Add replaceNode switch #141
Reference in New Issue
Block a user
Delete Branch "feature/add-replace-node-switch"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This adds a new default switch which is functionally the same as the
outerHTMLswitch, but usesNode.replaceChild()instead ofouterHTML, so it doesn't requireswitchElementsAlt.@robinnorth Should we consider using this as the default switch instead of
outerHTML?Would be good to know if there's any performance difference between the two switches (and any browser-specific known issues that need considering, not that I can think of any) before making it the new default. Making it the new default would also be a breaking change, so you'd have to do that in 0.3.0 (still think that should be 1.0.0!).
Based on this jsperf test,
replaceChildis 3x as fast asinnerHTML. Regardless, I don't think the practical difference will be more than a few milliseconds, since I doubt anyone is replacing more than a few elements.According to this (referenced by Caniuse),
parentNodeandreplaceChildare supported properly by all browsers.Absolutely. I would make a new PR for that after v0.2.6 is finished.
I rebased on master and force-pushed to be able to update the Typescript definitions.
Cool, all sounds good to me.