Skip to content

Commit addea43

Browse files
authored
docs: describe falsy and nullish attribute behavior (#4498)
1 parent d802c3b commit addea43

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

site/content/docs/02-template-syntax.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ Or they can *be* JavaScript expressions.
5858

5959
---
6060

61+
Boolean attributes are included on the element if their value is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy) and excluded if it's [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy).
62+
63+
All other attributes are included unless their value is [nullish](https://developer.mozilla.org/en-US/docs/Glossary/Nullish) (`null` or `undefined`).
64+
65+
```html
66+
<input required={false} placeholder="This input field is not required">
67+
<div title={null}>This div has no title attribute</div>
68+
```
69+
70+
---
71+
6172
An expression might include characters that would cause syntax highlighting to fail in regular HTML, so quoting the value is permitted. The quotes do not affect how the value is parsed:
6273

6374
```html

0 commit comments

Comments
 (0)