Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Putting this up for discussion. Currently, a SvelteKit app will often render HTML with relative paths, which are replaced with absolute paths upon hydration. (This behaviour is intentional — it means that the HTML is more portable and resilient, for example if it ends up on the Internet Archive or on IPFS. It will likely be the default for all base-relative paths in SvelteKit 2.0.)
The cost is that something like
<a href="{paths.base}/whatever">
will differ between SSR and CSR:<a href="../whatever">
<a href="https://example.com/foo/bar/whatever">
As a result, Svelte updates the attribute during hydration, even though it resolves to the same URL.
For
src
andsrcset
attributes, we always skip hydration, on the assumption that the resolved value will be unchanged. (In dev, we check that this is in fact the case.) We could do the same thing forhref
. The stakes are lower — whereas updatingsrc
can cause unnecessary network requests, or cause iframes to be reloaded, this is only about avoiding unnecessary work — but it's probably worthwhile anyway.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint