←back to thread

Element: setHTML() method

(developer.mozilla.org)
170 points todsacerdoti | 1 comments | | HN request time: 0.236s | source
Show context
sergeykish ◴[] No.45677170[source]
So `.setHTML("<script>...</script>")` does not set HTML?
replies(2): >>45677372 #>>45678816 #
1. xp84 ◴[] No.45677372[source]
Sounds reasonable enough to me. 99.99% of the times you’re in an actual script, if you mean to execute code, you’d just execute it yourself, rather than making a script tag full of code and sticking that tag into a random DOM element. That’s why the default wouldn’t honor the script tag and there’d be an “unsafe” method explicitly named as such to hint you that you’re doing something weird.