Skip to content

undefined props are serialized as null #7528

Closed
@wackbyte

Description

What version of astro are you using?

2.7.2

Are you using an SSR adapter? If so, which one?

Node

What package manager are you using?

pnpm

What operating system are you using?

Linux (NixOS)

What browser are you using?

Firefox (Librewolf)

Describe the Bug

When a Svelte component is hydrated, any props that are undefined become null. This has caused unexpected behavior and unsound typing (prop === null vs. prop === undefined) for me in the past.

In my example, it is shown that undefined props are indeed undefined when rendered on the server, but are hydrated with such props being null instead.

I have not tested whether this happens in other frameworks.

What's the expected result?

Any undefined props should remain undefined when hydrated.

Link to Minimal Reproducible Example

https://gitlab.com/wackbyte/astro-serializes-undefined-as-null

Participation

  • I am willing to submit a pull request for this issue.

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