mfreed7 / declarative-shadow-dom

Declarative Shadow DOM feature development
192 stars 9 forks source link

Simple Polyfill for setInnerHTML is wrong, cause dom parser also has "head" #23

Closed jogibear9988 closed 8 months ago

jogibear9988 commented 8 months ago

With set innerHTML you could also assing, script, link and other tags, wich the dom parser will move into the "head" section

mfreed7 commented 8 months ago

Thanks for the bug! Two notes:

  1. This explainer is out of date anyway, and I've added a note to that effect. The feature has been standardized, so MDN or the spec itself should be the authority. For example, the function is now called setHTML and not setInnerHTML.

  2. The polyfill should work correctly as-is. Note that it explicitly (and for exactly this reason) adds a <pre> tag around the contents, which triggers the body and avoids putting anything into the head, with a few exceptions that can't be avoided.

TechQuery commented 4 months ago

You can try the latest polyfill: https://github.com/EasyWebApp/declarative-shadow-dom-polyfill