Skip to content

Commit 5ddf4ca

Browse files
Epenancedummdidumm
andauthored
docs: fix attribute example in basic markup (#8813)
--------- Co-authored-by: Simon H <[email protected]>
1 parent ea18bd7 commit 5ddf4ca

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

documentation/docs/02-template-syntax/02-basic-markup.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ An expression might include characters that would cause syntax highlighting to f
6262
When the attribute name and value match (`name={name}`), they can be replaced with `{name}`.
6363

6464
```svelte
65-
<!-- These are equivalent -->
66-
<button {disabled}>...</button>
6765
<button {disabled}>...</button>
66+
<!-- equivalent to
67+
<button disabled={disabled}>...</button>
68+
-->
6869
```
6970

7071
By convention, values passed to components are referred to as _properties_ or _props_ rather than _attributes_, which are a feature of the DOM.

documentation/docs/02-template-syntax/05-element-directives.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,13 @@ The simplest bindings reflect the value of a property, such as `input.value`.
105105
<input type="checkbox" bind:checked={yes} />
106106
```
107107

108-
If the name matches the value, you can use shorthand.
108+
If the name matches the value, you can use a shorthand.
109109

110110
```svelte
111-
<!-- These are equivalent -->
112-
<input bind:value />
113111
<input bind:value />
112+
<!-- equivalent to
113+
<input bind:value={value} />
114+
-->
114115
```
115116

116117
Numeric input values are coerced; even though `input.value` is a string as far as the DOM is concerned, Svelte will treat it as a number. If the input is empty or invalid (in the case of `type="number"`), the value is `undefined`.
@@ -339,8 +340,8 @@ A `class:` directive provides a shorter way of toggling a class on an element.
339340

340341
```svelte
341342
<!-- These are equivalent -->
342-
<div class={active ? 'active' : ''}>...</div>
343-
<div class:active>...</div>
343+
<div class={isActive ? 'active' : ''}>...</div>
344+
<div class:active={isActive}>...</div>
344345
345346
<!-- Shorthand, for when name and value match -->
346347
<div class:active>...</div>

0 commit comments

Comments
 (0)