Skip to content

Uncaught DOMException when having <!DOCTYPE html> and setting the parentDom to document when rendering #3794

Closed
@rojvv

Description

@rojvv
  • 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:

  1. Open the above HTML in your browser.
  2. You will face the error.
  3. Try removing the first line, <!DOCTYPE html>.
  4. See how the error is gone.

Expected behavior
Should act just fine :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions