Skip to content

Commit d47f4f5

Browse files
authored
fix: expand boolean attribute support (#15095)
* Adding test for expected boolean attribute support * Improving support for more boolean attributes: Added: - `defer` - `disablepictureinpicture` - `disableremoteplayback` Improved: - `allowfullscreen` - `novalidate` * Skipping JSDOM version of boolean attribute test JSDOM lacks support for some attributes, so we'll skip it for now. See: - `async`: jsdom/jsdom#1564 - `nomodule`: jsdom/jsdom#2475 - `autofocus`: jsdom/jsdom#3041 - `inert`: jsdom/jsdom#3605 - etc...: jestjs/jest#139 (comment) * Adding changeset
1 parent d17f5c7 commit d47f4f5

File tree

4 files changed

+100
-3
lines changed

4 files changed

+100
-3
lines changed

.changeset/strange-hairs-trade.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: expand boolean attribute support

packages/svelte/src/utils.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ const DOM_BOOLEAN_ATTRIBUTES = [
170170
'reversed',
171171
'seamless',
172172
'selected',
173-
'webkitdirectory'
173+
'webkitdirectory',
174+
'defer',
175+
'disablepictureinpicture',
176+
'disableremoteplayback'
174177
];
175178

176179
/**
@@ -197,7 +200,10 @@ const ATTRIBUTE_ALIASES = {
197200
defaultvalue: 'defaultValue',
198201
defaultchecked: 'defaultChecked',
199202
srcobject: 'srcObject',
200-
novalidate: 'noValidate'
203+
novalidate: 'noValidate',
204+
allowfullscreen: 'allowFullscreen',
205+
disablepictureinpicture: 'disablePictureInPicture',
206+
disableremoteplayback: 'disableRemotePlayback'
201207
};
202208

203209
/**
@@ -219,7 +225,11 @@ const DOM_PROPERTIES = [
219225
'volume',
220226
'defaultValue',
221227
'defaultChecked',
222-
'srcObject'
228+
'srcObject',
229+
'noValidate',
230+
'allowFullscreen',
231+
'disablePictureInPicture',
232+
'disableRemotePlayback'
223233
];
224234

225235
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
// JSDOM lacks support for some of these attributes, so we'll skip it for now.
5+
//
6+
// See:
7+
// - `async`: https://github.com/jsdom/jsdom/issues/1564
8+
// - `nomodule`: https://github.com/jsdom/jsdom/issues/2475
9+
// - `autofocus`: https://github.com/jsdom/jsdom/issues/3041
10+
// - `inert`: https://github.com/jsdom/jsdom/issues/3605
11+
// - etc...: https://github.com/jestjs/jest/issues/139#issuecomment-592673550
12+
skip_mode: ['client'],
13+
14+
html: `
15+
<script nomodule async defer></script>
16+
<form novalidate></form>
17+
<input readonly required checked webkitdirectory>
18+
<select multiple disabled></select>
19+
<button formnovalidate></button>
20+
<img ismap>
21+
<video autoplay controls loop muted playsinline disablepictureinpicture disableremoteplayback></video>
22+
<audio disableremoteplayback></audio>
23+
<track default>
24+
<iframe allowfullscreen></iframe>
25+
<details open></details>
26+
<ol reversed></ol>
27+
<div autofocus></div>
28+
<span inert></span>
29+
30+
<script nomodule async defer></script>
31+
<form novalidate></form>
32+
<input readonly required checked webkitdirectory>
33+
<select multiple disabled></select>
34+
<button formnovalidate></button>
35+
<img ismap>
36+
<video autoplay controls loop muted playsinline disablepictureinpicture disableremoteplayback></video>
37+
<audio disableremoteplayback></audio>
38+
<track default>
39+
<iframe allowfullscreen></iframe>
40+
<details open></details>
41+
<ol reversed></ol>
42+
<div autofocus></div>
43+
<span inert></span>
44+
45+
<script></script>
46+
<form></form>
47+
<input>
48+
<select></select>
49+
<button></button>
50+
<img>
51+
<video></video>
52+
<audio></audio>
53+
<track>
54+
<iframe></iframe>
55+
<details></details>
56+
<ol></ol>
57+
<div></div>
58+
<span></span>
59+
`
60+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script>
2+
let runesMode = $state('using a rune so that we trigger runes mode');
3+
4+
const attributeValues = [true, 'test', false];
5+
</script>
6+
7+
{#each attributeValues as val}
8+
<script NOMODULE={val} ASYNC={val} DEFER={val}></script>
9+
<form NOVALIDATE={val}></form>
10+
<input READONLY={val} REQUIRED={val} CHECKED={val} WEBKITDIRECTORY={val} />
11+
<select MULTIPLE={val} DISABLED={val}></select>
12+
<button FORMNOVALIDATE={val}></button>
13+
<img ISMAP={val} />
14+
<video AUTOPLAY={val} CONTROLS={val} LOOP={val} MUTED={val} PLAYSINLINE={val} DISABLEPICTUREINPICTURE={val} DISABLEREMOTEPLAYBACK={val}></video>
15+
<audio DISABLEREMOTEPLAYBACK={val}></audio>
16+
<track DEFAULT={val} />
17+
<iframe ALLOWFULLSCREEN={val}></iframe>
18+
<details OPEN={val}></details>
19+
<ol REVERSED={val}></ol>
20+
<div AUTOFOCUS={val}></div>
21+
<span INERT={val}></span>
22+
{/each}

0 commit comments

Comments
 (0)