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
feature: Replace sveltekit:* with valid HTML attributes like data-sveltekit-* (#6170)
* WIP: Replace `sveltekit:prefetch` with `data-sveltekit-prefetch` at build time.
* WIP: Use svelte-preprocess to replace values. Significant progress!
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.
* Improve attribute replacement and make it work even if app devs have custom preprocessing config.
Auto-reloading doesn't work though, so that needs to be fixed, along with regex specificity.
* WIP: Explore how to combine the svelte config by the user with the options needed by sveltekit.
* Improve type definition for `config.preprocess` to match what's used internally. Also allow object configs.
* Use API from vite-plugin-svelte to add internal SvelteKit preprocessing
Much cleaner solution, which also should be a tiny bit more performant than before.
* Cleanup
* Breaking: Rename sveltekit:prefetch to data-sveltekit-precfetch
* Breaking: Rename sveltekit:noscroll to data-sveltekit-noscroll
* Breaking: Rename sveltekit:reload to data-sveltekit-reload
* print console error for removed attributes in dev
* lint
* Update packages/kit/types/index.d.ts
* Update packages/kit/types/index.d.ts
* Create neat-pots-flash.md
Co-authored-by: Rich Harris <[email protected]>
Copy file name to clipboardExpand all lines: documentation/docs/09-a-options.md
+9-9
Original file line number
Diff line number
Diff line change
@@ -2,16 +2,16 @@
2
2
title: Anchor options
3
3
---
4
4
5
-
### sveltekit:prefetch
5
+
### data-sveltekit-prefetch
6
6
7
7
SvelteKit uses code splitting to break your app into small chunks (one per route), ensuring fast startup times.
8
8
9
9
For _dynamic_ routes, such as our `src/routes/blog/[slug]/+page.svelte` example, that's not enough. In order to render the blog post, we need to fetch the data for it, and we can't do that until we know what `slug` is. In the worst case, that could cause lag as the browser waits for the data to come back from the server.
10
10
11
-
We can mitigate that by _prefetching_ the data. Adding a `sveltekit:prefetch` attribute to a link...
11
+
We can mitigate that by _prefetching_ the data. Adding a `data-sveltekit-prefetch` attribute to a link...
12
12
13
13
```html
14
-
<asveltekit:prefetchhref="blog/what-is-sveltekit">What is SvelteKit?</a>
14
+
<adata-sveltekit-prefetchhref="blog/what-is-sveltekit">What is SvelteKit?</a>
15
15
```
16
16
17
17
...will cause SvelteKit to run the page's `load` function as soon as the user hovers over the link (on a desktop) or touches it (on mobile), rather than waiting for the `click` event to trigger navigation. Typically, this buys us an extra couple of hundred milliseconds, which is the difference between a user interface that feels laggy, and one that feels snappy.
@@ -20,28 +20,28 @@ Note that prefetching will not work if the [`router`](/docs/page-options#router)
20
20
21
21
You can also programmatically invoke `prefetch` from `$app/navigation`.
22
22
23
-
### sveltekit:reload
23
+
### data-sveltekit-reload
24
24
25
25
By default, the SvelteKit runtime intercepts clicks on `<a>` elements and bypasses the normal browser navigation for relative (same-origin) URLs that match one of your page routes. We sometimes need to tell SvelteKit that certain links need to be handled by normal browser navigation. Examples of this might be linking to another page on your domain that's not part of your SvelteKit app or linking to an endpoint.
26
26
27
-
Adding a `sveltekit:reload` attribute to a link...
27
+
Adding a `data-sveltekit-reload` attribute to a link...
28
28
29
29
```html
30
-
<asveltekit:reloadhref="path">Path</a>
30
+
<adata-sveltekit-reloadhref="path">Path</a>
31
31
```
32
32
33
33
...will cause browser to navigate via a full page reload when the link is clicked.
34
34
35
35
Links with a `rel="external"` attribute will receive the same treatment. In addition, they will be ignored during [prerendering](https://kit.svelte.dev/docs/page-options#prerender).
36
36
37
-
### sveltekit:noscroll
37
+
### data-sveltekit-noscroll
38
38
39
39
When navigating to internal links, SvelteKit mirrors the browser's default navigation behaviour: it will change the scroll position to 0,0 so that the user is at the very top left of the page (unless the link includes a `#hash`, in which case it will scroll to the element with a matching ID).
40
40
41
-
In certain cases, you may wish to disable this behaviour. Adding a `sveltekit:noscroll` attribute to a link...
41
+
In certain cases, you may wish to disable this behaviour. Adding a `data-sveltekit-noscroll` attribute to a link...
42
42
43
43
```html
44
-
<ahref="path"sveltekit:noscroll>Path</a>
44
+
<ahref="path"data-sveltekit-noscroll>Path</a>
45
45
```
46
46
47
47
...will prevent scrolling after the link is clicked.
0 commit comments