Skip to content

Commit

Permalink
Merge pull request #68 from sveltejs/master
Browse files Browse the repository at this point in the history
docs: describe falsy and nullish attribute behavior (sveltejs#4498)
  • Loading branch information
sthagen authored Mar 2, 2020
2 parents b941005 + addea43 commit 55d6560
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions site/content/docs/02-template-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ Or they can *be* JavaScript expressions.

---

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).

All other attributes are included unless their value is [nullish](https://developer.mozilla.org/en-US/docs/Glossary/Nullish) (`null` or `undefined`).

```html
<input required={false} placeholder="This input field is not required">
<div title={null}>This div has no title attribute</div>
```

---

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:

```html
Expand Down

0 comments on commit 55d6560

Please sign in to comment.