News for hackers. Stuff that matters.
Re:Goodbye InnerHTML, Hello SetHTML: Stronger XSS Protection... by iLoveOncall on Tuesday February 24, 2026 @01:44PM (#47140906)
But that's what setHTML isn't at all a replacement for innerHTML.

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.

Re:Goodbye InnerHTML, Hello SetHTML: Stronger XSS Protection... by Dylan16807 on Tuesday February 24, 2026 @04:30PM (#47143362)
> You still need innerHTML when you want to inject HTML tags in the page

What makes you say this?

Re:Goodbye InnerHTML, Hello SetHTML: Stronger XSS Protection... by joquarky on Tuesday February 24, 2026 @08:56PM (#47146333)
> need innerHTML

parent.appendChild(document.createElement(tag))

Re:Goodbye InnerHTML, Hello SetHTML: Stronger XSS Protection... by iLoveOncall on Wednesday February 25, 2026 @03:32AM (#47148897)
How is adding an element to the parent the same as replacing all the content of the element? You guys are exhausting. Think a bit before spouting nonsense?
Re:Goodbye InnerHTML, Hello SetHTML: Stronger XSS Protection... by chrisldgk on Thursday February 26, 2026 @11:50AM (#47168586)
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?