`setHTML` is meant as a replacement for `innerHTML`. In the use case you describe, you would have never wanted `innerHTML` anyway. You'd want `innerText` or `textContent`.
It’s simple, you use innerHTML if you know for sure where the input comes from and if it’s safe (for example when you define it as a hard coded string in your own code).
You use setHTML when you need to render HTML that is potentially unsafe (for example forum posts or IM messages). Honest question, which part of that isn’t clear?
iLoveOncall|6 days ago
You still need innerHTML when you want to inject HTML tags in the page, and you could already use innerText when you didn't want to.
Having something in between is seriously useless.
chrisldgk|4 days ago
Dylan16807|6 days ago
What makes you say this?
joquarky|6 days ago
parent.appendChild(document.createElement(tag))