Skip to content

Commit ddee94c

Browse files
Conduitrytaylorzane
authored andcommitted
docs: describe falsy and nullish attribute behavior (sveltejs#4498)
1 parent 9d7e296 commit ddee94c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

+11
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)