<style> elements are handled incorrectly when set via .innerHTML
bqx opened this issue · 0 comments
bqx commented
This happens because of the following line in the parse
function: const parsed = parser.parseFromString(html, 'text/html').body;
It turns out that the DOMParser
will try to put the <style>
element in the <head>
, so instead of the <style>
element this will return nothing.
It looks like wrapping the <style>
element in a <div>
will keep it in the body, so a simple solution would be to wrap the html in a container element before parsing it.