Re:Goodbye InnerHTML, Hello SetHTML: Stronger XSS Protection...
by Aachen on Tuesday February 24, 2026 @10:15AM
(#47138212)
> maybe third time could be the charm: it's for preventing XSS holes
That information is in the question, so sadly no this still doesn't make sense to me because I don't understand any scenario in which this is what the developer wants. You always still need more code (to filter the right tags) or can just use textContent (separating data and code completely, imo the recommended solution)
> Maybe you meant .innerHTML? .innerText AFAIK doesn't try to parse HTML (why would it?)
No, I didn't mean that, yes it does, and no I don't know why it is this way. If you don't believe me and don't want to check it out for yourself, I'm not sure what more I can say
Re:Goodbye InnerHTML, Hello SetHTML: Stronger XSS Protection...
by lelanthran on Tuesday February 24, 2026 @01:36PM
(#47140795)
> I don't understand any scenario in which this is what the developer wants.
Client-side includes.
Maybe you meant .innerHTML? .innerText AFAIK doesn't try to parse HTML (why would it?), but I don't understand what you mean with nonstandard, both .innerHTML and .innerText are part of the standards, and I think they've been for a long time.
> but I didn't understand what the point of this default could be and so why it exists (a sibling comment proposed a plausible answer: hardening on top of another solution) [...] the question "what's the use-case for this"
I guess maybe third time could be the charm: it's for preventing XSS holes that are very common when people use .innerHTML