You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
If you inspect the href in the browser it is "./some/path" even after hydration.
When using component libraries, it's quite common to spread props on all sorts of elements, to allow users to specify any valid pops and pass it through to the native html element. Which would then make it impossible to use base as part of the url/href you send to the component.
Example:
<script>
import { base } from "$app/paths";
import { Link } from "some-component-library";
</script>
<Link href="{base}/some/path">Broken url</Link>
Our current workaround is to wrap every Link component that uses base in {#if browser} which isn't the nicest.
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 inhref
on thea
tag, this functionality breaks.Reproduction
I've created a simple example here It includes 3 links in the layout file
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.Here is the
LinkButton
component for simplicityChanging it to this
solves the issue
Logs
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: