Skip to content

Unhelpful error message when dealing with invalid markup #15502

Open
@peterreeves

Description

@peterreeves

Describe the bug

I've got an old v3 project that I've been upgrading to v5. I had two components, a parent component that was rendering a table, and a child component that was rendering table rows. The child also had some markup that was invalid (a child outside the <tr> element), but v3 ran with no issues. However v5 throws an unhelpful "dom is null" error. Weirdly, this only happens once I add an event handler to the markup.

This took me quite a while to find, since the error was extremely unhelpful and did not point me in the right direction. To be clear I think a better error would be nice in dev mode, in prod it's fine as is.

Reproduction

https://svelte.dev/playground/a717f2e8e91e4117940ff4bf805c8e23?version=5.23.0

Logs

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 15.93 GB / 31.91 GB
  Binaries:
    Node: 22.5.1 - C:\Program Files\nodejs\node.EXE
    npm: 10.9.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.15.5 - ~\AppData\Local\pnpm\pnpm.CMD
  Browsers:
    Edge: Chromium (131.0.2903.86)
    Internet Explorer: 11.0.26100.1882

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions