Skip to content

repair href attribute mismatches from a component using spread props and resolveRoute #15120

Closed
@AndreasHald

Description

@AndreasHald

Describe the bug

in #13032 @dummdidumm talks about when href are server side generated they are rendered with relative paths, however on the client they need to be absolute so when the application hydrates it replaces the href with an absolute instead of a relative.

It creates a bit of an edge case where if you put links in a layout file and navigate up/down the paths break if they are not absolute.

It appears that if you use resolveRoute and a component that spread in href on the a tag, this functionality breaks.

Reproduction

I've created a simple example here It includes 3 links in the layout file

Image

If you serve the app and go to /bar and inspect the links, you can see that 2 of them has been hydrated from relative -> absolute urls, however the third has not.

Image

Here is the LinkButton component for simplicity
Image

Changing it to this
Image
solves the issue

Logs

System Info

System:
    OS: macOS 15.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 719.09 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.12.0 - ~/.nvm/versions/node/v22.12.0/bin/node
    npm: 10.9.0 - ~/.nvm/versions/node/v22.12.0/bin/npm
  Browsers:
    Chrome: 131.0.6778.265
    Safari: 18.2
  npmPackages:
    svelte: ^5.0.0 => 5.19.3

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