You can throw away innerHTML and replace it with the new setHTML(), which has a built-in sanitizer. Here's how it works:

@firefoxwebdevs Looks great but why is it called setHTML? What is the ‘set’ supposed to mean?

#WebDev #HTML

@LeonardoDiOttio I see what you're getting at, but replaceChildrenWithParsedHTML is a bit long.

Fwiw when you set innerHTML you're not really setting the HTML either.