Skip to content

Replace function fails if root fragment cannot be found #2

@danielvaughn

Description

@danielvaughn

When executing replace(), the root fragment needs to exist in the DOM else it throws an error.

Expected Behavior

Given this html:

<body>
  <main></main>
</body>

And this JSX:

replace(
  <main id="app">
    <h1>hello world</h1>
  </main>
)

The expectation would be that the function would either fail silently, or emit a warning with a description of what went wrong. At the very least, it should not halt execution of the program.

Observed Behavior

It throws the following uncaught exception:

Uncaught TypeError: Cannot read properties of null (reading 'replaceChildren')

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions