From b36975aee5ce0699f947ce3197acda7980587048 Mon Sep 17 00:00:00 2001 From: Tee Ming Date: Tue, 15 Aug 2023 04:27:16 +0800 Subject: [PATCH 1/2] add 'false' value to preload link options --- .changeset/bright-buttons-flash.md | 5 +++++ documentation/docs/30-advanced/30-link-options.md | 6 +++--- packages/kit/src/runtime/client/constants.js | 3 ++- packages/kit/src/runtime/client/utils.js | 4 ++-- 4 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 .changeset/bright-buttons-flash.md diff --git a/.changeset/bright-buttons-flash.md b/.changeset/bright-buttons-flash.md new file mode 100644 index 000000000000..47ef3b12efcd --- /dev/null +++ b/.changeset/bright-buttons-flash.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: allow `"false"` value for preload link options diff --git a/documentation/docs/30-advanced/30-link-options.md b/documentation/docs/30-advanced/30-link-options.md index 37d3c3a4c35f..3994ff3fd688 100644 --- a/documentation/docs/30-advanced/30-link-options.md +++ b/documentation/docs/30-advanced/30-link-options.md @@ -122,8 +122,8 @@ To disable any of these options inside an element where they have been enabled, ``` -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 -
+```svelte +
``` \ No newline at end of file diff --git a/packages/kit/src/runtime/client/constants.js b/packages/kit/src/runtime/client/constants.js index cbb2353ed2be..e6b515332801 100644 --- a/packages/kit/src/runtime/client/constants.js +++ b/packages/kit/src/runtime/client/constants.js @@ -7,5 +7,6 @@ export const PRELOAD_PRIORITIES = /** @type {const} */ ({ hover: 2, viewport: 3, eager: 4, - off: -1 + off: -1, + false: -1 }); diff --git a/packages/kit/src/runtime/client/utils.js b/packages/kit/src/runtime/client/utils.js index 8af6102cd93f..4ce100dbb7db 100644 --- a/packages/kit/src/runtime/client/utils.js +++ b/packages/kit/src/runtime/client/utils.js @@ -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'], From fb4f7f00216551a88e674944e09c385f70208aac Mon Sep 17 00:00:00 2001 From: Tee Ming Date: Wed, 16 Aug 2023 18:13:09 +0800 Subject: [PATCH 2/2] Update documentation/docs/30-advanced/30-link-options.md Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> --- documentation/docs/30-advanced/30-link-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/docs/30-advanced/30-link-options.md b/documentation/docs/30-advanced/30-link-options.md index 3994ff3fd688..4d2445a59f59 100644 --- a/documentation/docs/30-advanced/30-link-options.md +++ b/documentation/docs/30-advanced/30-link-options.md @@ -125,5 +125,5 @@ To disable any of these options inside an element where they have been enabled, To apply an attribute to an element conditionally, do this: ```svelte -
+
``` \ No newline at end of file