Skip to content

Commit 8241096

Browse files
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 <[email protected]>
1 parent c8865bb commit 8241096

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

.changeset/quiet-planets-carry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: treat `inert` as a boolean attribute

packages/svelte/src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ const DOM_BOOLEAN_ATTRIBUTES = [
156156
'formnovalidate',
157157
'hidden',
158158
'indeterminate',
159+
'inert',
159160
'ismap',
160161
'loop',
161162
'multiple',
@@ -214,7 +215,6 @@ const DOM_PROPERTIES = [
214215
'playsInline',
215216
'readOnly',
216217
'value',
217-
'inert',
218218
'volume',
219219
'defaultValue',
220220
'defaultChecked',
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
import { ok, test } from '../../test';
1+
import { test } from '../../test';
22

33
export default test({
4+
ssrHtml: `
5+
<div></div>
6+
<div inert="">some div <button>click</button></div>
7+
`,
8+
49
get props() {
510
return { inert: true };
611
},
12+
713
test({ assert, target, component }) {
8-
const div = target.querySelector('div');
9-
ok(div);
10-
assert.ok(div.inert);
14+
const [div1, div2] = target.querySelectorAll('div');
15+
assert.ok(!div1.inert);
16+
assert.ok(div2.inert);
17+
1118
component.inert = false;
12-
assert.ok(!div.inert);
19+
assert.ok(!div2.inert);
1320
}
1421
});

packages/svelte/tests/runtime-legacy/samples/attribute-boolean-inert/main.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
export let inert;
33
</script>
44

5+
<div inert={false}></div>
56
<div {inert}>some div <button>click</button></div>

0 commit comments

Comments
 (0)