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

@annevk @domenic if I understand correctly the main argument for _not_ adding method proposed here is "hey, we've got something like this already in the form of `x.textContent=""` or `x.innerHTML=""` and existing solution are as concise to write as `x.removeChildren()`".

While I completely agree with this reasoning IMO the "ergonomics" should be seen in the broader context and not only number of characters to type. For me the _main_ issue with lack of sth like `x.removeChildren()` is that people spending brain cycles (to figure out _which_ method to use) and CPU cycles (to benchmark various methods of clearing up nodes). As an example you can check a popular JS framework benchmark that _agonizes_  over various ways of removing all children of a given DOM element: https://github.com/krausest/js-framework-benchmark/blob/f1cdea5d9f8472fe12148f079ea9623915a6c498/vanillajs-non-keyed/src/Main.js#L262-L284

I'm completely subscribing to the idea of keeping the platform APIs as simple and small as possible. But IMO the addition proposed here is valuable not because it will save few keystrokes  - for me the main benefit would be a "platform-blessed" way of clearing children. This in turn could people less anxious about having too many choices and would ultimately make people happier :-)

I guess tl'dr; is that I would like to add +1 for the proposal (whatever the final method name is).

-- 
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-318043884

Received on Wednesday, 26 July 2017 12:53:01 UTC