Re: [whatwg/dom] Proposal: ParentNode.empty() (#478)

I'll note as a library maintainer (Mithril, a vdom-based framework), something like `replaceAll` or even `clear` would be useful for optimizing the case of patching an entire tree where the whole thing needs rewritten (think: `m("div.foo", [cond ? m("div.bar") : undefined])`). We already do similar optimizations for strings with `textContent`, but if we had a way to avoid a recursive loop, that'd be nice.

(FWIW, browsers could optimize this case to just detaching the first and last child and setting `previousSibling` and `nextSibling` both for all the children to `null`, which is a lot quicker than what library writers could do. They could also more efficiently recalculate layout.)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/478#issuecomment-354343375

Received on Thursday, 28 December 2017 19:26:42 UTC