You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes attribute rendering for non-[boolean HTML attributes](https://developer.mozilla.org/en-US/docs/Glossary/Boolean/HTML) with boolean values to match proper attribute handling in browsers.
6
+
7
+
Previously, non-boolean attributes may not have included their values when rendered to HTML. In Astro v5.0, the values are now explicitly rendered as `="true"` or `="false"`
8
+
9
+
In the following `.astro` examples, only `allowfullscreen` is a boolean attribute:
10
+
11
+
```astro
12
+
<!-- src/pages/index.astro -->
13
+
<!-- `allowfullscreen` is a boolean attribute -->
14
+
<p allowfullscreen={true}></p>
15
+
<p allowfullscreen={false}></p>
16
+
17
+
<!-- `inherit` is *not* a boolean attribute -->
18
+
<p inherit={true}></p>
19
+
<p inherit={false}></p>
20
+
21
+
<!-- `data-*` attributes are not boolean attributes -->
22
+
<p data-light={true}></p>
23
+
<p data-light={false}></p>
24
+
```
25
+
26
+
Astro v5.0 now preserves the full data attribute with its value when rendering the HTML of non-boolean attributes:
27
+
28
+
```diff
29
+
<p allowfullscreen></p>
30
+
<p></p>
31
+
32
+
<p inherit="true"></p>
33
+
- <p inherit></p>
34
+
+ <p inherit="false"></p>
35
+
36
+
- <p data-light></p>
37
+
+ <p data-light="true"></p>
38
+
- <p></p>
39
+
+ <p data-light="false"></p>
40
+
```
41
+
42
+
If you rely on attribute values, for example to locate elements or to conditionally render, update your code to match the new non-boolean attribute values:
0 commit comments