In JavaScript, when we want to empty or replace the content of a container element, we... presumably... do this:
Now, we have replaceChildren() — documentation on MDN.
It was added mid-2020, part of the DOM Living Standard, first implemented in browsers between mid and late 2020 (around the ECMAScript 2020 timeframe, though technically not an ES feature). ES = ECMAScript, not Espagnol.
Usage
newNode and otherNewNode are variables.
For instance:
The container.replaceChildren(newNode, otherNewNode); is equivalent to:
Because we cannot use innerHTML to append DOM nodes.
But we can do this:
So it depends on the things we build.
Replace Children
Anyway, it sounds like the changeling committee SOP.
Meeting minutes: Item 7 — Replace Children. Committee unanimously agrees to proceed with the changeling programme.
Cheers!
