From 8241096b06d5dfb2fc5374ce704e6b30c01e26dd Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Tue, 7 Jan 2025 20:24:53 +0100 Subject: [PATCH] fix: treat `inert` as a boolean attribute (#14935) * fix: treat `inert` as a boolean attribute fixes #14731 * remove solo: true --------- Co-authored-by: Rich Harris --- .changeset/quiet-planets-carry.md | 5 +++++ packages/svelte/src/utils.js | 2 +- .../samples/attribute-boolean-inert/_config.js | 17 ++++++++++++----- .../samples/attribute-boolean-inert/main.svelte | 1 + 4 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 .changeset/quiet-planets-carry.md diff --git a/.changeset/quiet-planets-carry.md b/.changeset/quiet-planets-carry.md new file mode 100644 index 0000000000..0abeffa2e8 --- /dev/null +++ b/.changeset/quiet-planets-carry.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: treat `inert` as a boolean attribute diff --git a/packages/svelte/src/utils.js b/packages/svelte/src/utils.js index e42721b4f4..76486d32ac 100644 --- a/packages/svelte/src/utils.js +++ b/packages/svelte/src/utils.js @@ -156,6 +156,7 @@ const DOM_BOOLEAN_ATTRIBUTES = [ 'formnovalidate', 'hidden', 'indeterminate', + 'inert', 'ismap', 'loop', 'multiple', @@ -214,7 +215,6 @@ const DOM_PROPERTIES = [ 'playsInline', 'readOnly', 'value', - 'inert', 'volume', 'defaultValue', 'defaultChecked', diff --git a/packages/svelte/tests/runtime-legacy/samples/attribute-boolean-inert/_config.js b/packages/svelte/tests/runtime-legacy/samples/attribute-boolean-inert/_config.js index 1322d63b7a..26fbbc955b 100644 --- a/packages/svelte/tests/runtime-legacy/samples/attribute-boolean-inert/_config.js +++ b/packages/svelte/tests/runtime-legacy/samples/attribute-boolean-inert/_config.js @@ -1,14 +1,21 @@ -import { ok, test } from '../../test'; +import { test } from '../../test'; export default test({ + ssrHtml: ` +
+
some div
+ `, + get props() { return { inert: true }; }, + test({ assert, target, component }) { - const div = target.querySelector('div'); - ok(div); - assert.ok(div.inert); + const [div1, div2] = target.querySelectorAll('div'); + assert.ok(!div1.inert); + assert.ok(div2.inert); + component.inert = false; - assert.ok(!div.inert); + assert.ok(!div2.inert); } }); diff --git a/packages/svelte/tests/runtime-legacy/samples/attribute-boolean-inert/main.svelte b/packages/svelte/tests/runtime-legacy/samples/attribute-boolean-inert/main.svelte index 6c3df7e31e..3b97923713 100644 --- a/packages/svelte/tests/runtime-legacy/samples/attribute-boolean-inert/main.svelte +++ b/packages/svelte/tests/runtime-legacy/samples/attribute-boolean-inert/main.svelte @@ -2,4 +2,5 @@ export let inert; +
some div