-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: Replace sveltekit:*
with valid HTML attributes like data-sveltekit-*
#6170
feature: Replace sveltekit:*
with valid HTML attributes like data-sveltekit-*
#6170
Conversation
PoC works great if run from the user's svelte.config.js, but we need to extend the user config and still make it work. Currently it only works when run with the default svelte config loading.
…custom preprocessing config. Auto-reloading doesn't work though, so that needs to be fixed, along with regex specificity.
…tions needed by sveltekit.
…internally. Also allow object configs.
Much cleaner solution, which also should be a tiny bit more performant than before.
🦋 Changeset detectedLatest commit: 9c42c90 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I went ahead and converted this to an actual draft PR and removed |
sveltekit:*
with valid HTML attributes like data-sveltekit-*
sveltekit:*
with valid HTML attributes like data-sveltekit-*
Thank you for the PR. If we're going to do this — and I'm not personally convinced it's necessary, though it's something we should resolve before 1.0 — then it should be a breaking change, i.e. we should require people to write |
Thanks! That's fair enough - using This was a really fun experiment to learn more about how SvelteKit works, and that the preproccessing approach actually was possible. However, just because it's possible doesn't mean it's the best approach. Though, not gonna lie it was exciting when I found a way to extend Next steps
Which approach is preferred? I'd say throwing a warning is the best approach for this (since it's such a simple breaking change), and then removing the warning for
|
Personally I prefer the existing |
Arguably, yeah. We'd need to support multiple options, of course: <a href="/whatever" data-sveltekit="prefetch noscroll"> It might get more complicated if we add attributes with options — e.g. there's been talk of <a href="/whatever" data-sveltekit="prefetch=viewport,ratio=0.5 noscroll"> ...which could become annoying to parse when there are multiple values, depending on how complex the options end up being. |
Hmm yeah that's tricky. If arguments are going to be the edge case I still think key value pairs for the majority is cleaner. FWIW I agree with the comment you made on the other thread, saying |
Update: we discussed this at the weekend and concluded that the responsible, grown-up thing to do would be to use valid HTML, because it would really suck if someone had a boss or client that demanded W3C-compliant HTML and couldn't use SvelteKit as a result. Separately, we decided it'd be cool if we could enable prefetching for an entire subtree of elements (or your entire app, if you put it on <nav>
<svg viewBox="0 0 2 3" aria-hidden="true">
<path d="M0,0 L1,2 C1.5,3 1.5,3 2,3 L2,0 Z" />
</svg>
- <ul>
+ <ul data-sveltekit-prefetch>
<li class:active={$page.url.pathname === '/'}>
- <a data-sveltekit-prefetch href="/">Home</a>
+ <a href="/">Home</a>
</li>
<li class:active={$page.url.pathname === '/about'}>
- <a data-sveltekit-prefetch href="/about">About</a>
+ <a href="/about">About</a>
</li>
<li class:active={$page.url.pathname === '/todos'}>
- <a data-sveltekit-prefetch href="/todos">Todos</a>
+ <a href="/todos">Todos</a>
</li>
</ul>
<svg viewBox="0 0 2 3" aria-hidden="true">
<path d="M0,0 L0,3 C0.5,3 0.5,3 1,2 L2,0 Z" />
</svg>
</nav> Going to do that in a separate PR though so it doesn't get in the way of this one. |
Migration
Replace all occurences of
sveltekit:reload
withdata-sveltekit-reload
sveltekit:prefetch
withdata-sveltekit-prefetch
sveltekit:noscroll
withdata-sveltekit-noscroll
PR description
I'm opening this early draft PR to track our progress to fix #3186
Goals
Replace
sveltekit:*
attributes (where*
isprefetch
,noscroll
orreload
) with valid HTML attributesdata-sveltekit-*
.sveltekit:prefetch
seems to be invalid HTML #3186 without a breaking change for app developers.vite-plugin-svelte
, which extends any customconfig.preprocess
defined by app developers.config.preprocess
to improve DX insvelte.config.js
files.Remaining TODOs:
svelte-preprocess
. Help appreciated in this area.Scrolling › scroll is restored after hitting the back button
svelte-kit package
when building components etc.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0