Skip to content

Commit

Permalink
fix: treat inert as a boolean attribute (#14935)
Browse files Browse the repository at this point in the history
* fix: treat `inert` as a boolean attribute

fixes #14731

* remove solo: true

---------

Co-authored-by: Rich Harris <[email protected]>
  • Loading branch information
dummdidumm and Rich-Harris authored Jan 7, 2025
1 parent c8865bb commit 8241096
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-planets-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: treat `inert` as a boolean attribute
2 changes: 1 addition & 1 deletion packages/svelte/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const DOM_BOOLEAN_ATTRIBUTES = [
'formnovalidate',
'hidden',
'indeterminate',
'inert',
'ismap',
'loop',
'multiple',
Expand Down Expand Up @@ -214,7 +215,6 @@ const DOM_PROPERTIES = [
'playsInline',
'readOnly',
'value',
'inert',
'volume',
'defaultValue',
'defaultChecked',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import { ok, test } from '../../test';
import { test } from '../../test';

export default test({
ssrHtml: `
<div></div>
<div inert="">some div <button>click</button></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);
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
export let inert;
</script>

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

0 comments on commit 8241096

Please sign in to comment.