This adds a new default switch which is functionally the same as the outerHTML switch, but uses Node.replaceChild() instead of outerHTML, so it doesn't require switchElementsAlt.
This adds a new default switch which is functionally the same as the `outerHTML` switch, but uses `Node.replaceChild()` instead of `outerHTML`, so it doesn't require `switchElementsAlt`.
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!).
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!).
Would be good to know if there's any performance difference between the two switches
Based on this jsperf test, replaceChild is 3x as fast as innerHTML. 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.
(and any browser-specific known issues that need considering, not that I can think of any)
According to this (referenced by Caniuse), parentNode and replaceChild are supported properly by all browsers.
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!).
Absolutely. I would make a new PR for that after v0.2.6 is finished.
>Would be good to know if there's any performance difference between the two switches
Based on [this jsperf test](https://jsperf.com/replacechild-vs-outerhtml-efficiency), `replaceChild` is 3x as fast as `innerHTML`. 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.
> (and any browser-specific known issues that need considering, not that I can think of any)
According to [this](https://quirksmode.org/dom/core/) (referenced by [Caniuse](https://www.caniuse.com/#search=replacechild)), `parentNode` and `replaceChild` are supported properly by all browsers.
>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!).
Absolutely. I would make a new PR for that after v0.2.6 is finished.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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.