Good day. 🎩
In JavaScript, when we want to empty or replace the content of a container element, we usually 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:
newNode and otherNewNode are variables. Didn't I just type that?
That container.replaceChildren(newNode, otherNewNode); above is equivalent with:
Because we can't use innerHTML to append DOM nodes.
But we can do this:
So it depends on the things we... build. Sometimes we can just use string, sometimes we can only create DOM node first because of the elaborate element we need to show or just a confusing flow we made.
Look at me, I'm an architect, for confusing myself. Go independent confusion.
Replace Children
It sounds like the changeling committee SOP.
Meeting minutes: Item 7 — Replace Children. Committee unanimously agrees to proceed with the changeling programme.
Until next time. 🎩


Comments
Post a Comment