Skip to content

perf: Svelte 5 hydration comparisons failing #9479

@benmccann

Description

@benmccann

Describe the bug

My site has some code:

<button aria-expanded={ showing === i} ... />

The aria-expanded attribute is a boolean, but gets compared to a string. As a result, the hydration code believes that the DOM needs to be updated which is a relatively expensive operation

I've included some suggestions from Rich and Dominik below regarding fixes

Screenshot from 2023-11-15 13-33-52

Screenshot from 2023-11-15 13-35-16

Reproduction

Simply put the code above in a SvelteKit project

Logs

No response

System Info

I'm on `5.0.0-next.1`

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions