Uncaught DOMException when having `<!DOCTYPE html>` and setting the `parentDom` to `document` when rendering
See original GitHub issue- Check if updating to the latest Preact version resolves the issue
Describe the bug
If we have <!DOCTYPE html>
in our HTML document where we use Preact, and try to render or hydrate a component in the document
, we get an Uncaught DOMException error, and the component does not render/hydrate. Although, it’ll be fine if we remove <!DOCTYPE html>
. This is very a strange behavior.
To Reproduce
<!DOCTYPE html>
<html>
<body>
</body>
</html>
<script type="module">
import { h, Component, render } from 'https://unpkg.com/preact?module';
const app = h('html', null, h('body', null, h('h1', null, 'Hello World!')));
render(app, document);
</script>
Steps to reproduce the behavior:
- Open the above HTML in your browser.
- You will face the error.
- Try removing the first line,
<!DOCTYPE html>
. - See how the error is gone.
Expected behavior Should act just fine 😃
Issue Analytics
- State:
- Created 10 months ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Rendering raw Html sources in React using doesn't show the ...
The problem, the body style of the Html sources doesn't show as we expected. For example: let's say we have this; <!DOCTYPE html> ......
Read more >Issues · preactjs/preact - GitHub
Uncaught DOMException when having <!DOCTYPE html> and setting the parentDom to document when rendering 11.x compat enhancement known issue The issue is ...
Read more >Fix Your Site With the Right DOCTYPE! - A List Apart
Since the tag provides a valid location on the web, the browser knows where to find it, and will render your document in...
Read more >Node.removeChild() - Web APIs - MDN Web Docs
To remove a specified element without having to specify its parent node: let node = document.getElementById("nested"); if (node.
Read more >HTML Document Type <!DOCTYPE html> Declaration
Placing a doctype at the beginning of a webpage can prevent weird display issues and help with rendering consistency across browser.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Shouldn’t this be rendering into
document.documentElement
?I’d like to support this in Preact, since Remix is already relying on it.
That doesn’t match my experience, but I’m curious to learn more. Can you share some links to projects which do that in the way you’re describing?