Skip to content
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

fix: add "false" value to preload link options #10555

Merged
merged 2 commits into from Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/bright-buttons-flash.md
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: allow `"false"` value for preload link options
6 changes: 3 additions & 3 deletions documentation/docs/30-advanced/30-link-options.md
Expand Up @@ -122,8 +122,8 @@ To disable any of these options inside an element where they have been enabled,
</div>
```

To apply an attribute to an element conditionally, do this (`"true"` and `"false"` are both accepted values):
To apply an attribute to an element conditionally, do this:

```html
<div data-sveltekit-reload={shouldReload}>
```svelte
<div data-sveltekit-preload-data={condition ? 'hover' : false}>
```
3 changes: 2 additions & 1 deletion packages/kit/src/runtime/client/constants.js
Expand Up @@ -7,5 +7,6 @@ export const PRELOAD_PRIORITIES = /** @type {const} */ ({
hover: 2,
viewport: 3,
eager: 4,
off: -1
off: -1,
false: -1
});
4 changes: 2 additions & 2 deletions packages/kit/src/runtime/client/utils.js
Expand Up @@ -30,8 +30,8 @@ const warned = new WeakSet();
/** @typedef {keyof typeof valid_link_options} LinkOptionName */

const valid_link_options = /** @type {const} */ ({
'preload-code': ['', 'off', 'tap', 'hover', 'viewport', 'eager'],
'preload-data': ['', 'off', 'tap', 'hover'],
'preload-code': ['', 'off', 'false', 'tap', 'hover', 'viewport', 'eager'],
'preload-data': ['', 'off', 'false', 'tap', 'hover'],
keepfocus: ['', 'true', 'off', 'false'],
noscroll: ['', 'true', 'off', 'false'],
reload: ['', 'true', 'off', 'false'],
Expand Down