Post

rip bozo innerHTML

3 reposts61 likes

You can't remove the safety from setHTML fwiw. It will always enforce a baseline that prevents XSS. The default sanitizer just also removes a lot of other things. You can do setHTML("", {sanitizer: {}}) to get the absolute minimum safety. There's lots of flexibility in the API though.

For when you *really* need to inject script dynamically via the parser you can use setHTMLUnsafe, which also takes a sanitizer in supporting browsers. So you essentially never need to use innerHTML once this is baseline.