Closed omar-azmi closed 4 days ago
I've tried a few things in web browsers (chromium and firefox), and seems like DOMParser.prototype.parseFromString
does in fact forcefully push custom elements in the head to the body.
In other words, the behavior of this library is consistent with browser implementations.
I imagine that changing the behavior would not only be a non-goal, but also extremely difficult, given that it relies on servo's html5ever
crate.
So, please feel free to close this issue if that is the case.
Yeah since deno-dom relies on html5ever
which is a standards-compliant HTML parser, so "preventing" this behaviour would be adding non-conforming logic.
Hello, I noticed that
parseFromString
tends to push all elements in the<head>
to the<body>
as soon as it encounters either a custom element, or an element that is not intended for the head (such as<div>
or<span>
).Example:
This produces the (prettified) html:
The expected output should have been:
From what I've tested, this seems to be an issue with the
parseFromString
method, and not theouterHTML
accessor, because if I replace an element inside of the head (e.g.element.replaceWith(doc.createElement("custom-element"))
), then the custom element is not pushed into the body instead.Is this by design? Because it certainly makes it extremely inconvenient to make transformations to head elements.
Thanks in advance!