Skip to content

Commit de43762

Browse files
authored
docs: add some missing details around string coercion and handling of nullish values (#15739)
closes #14716
1 parent fd0bc29 commit de43762

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

documentation/docs/02-runes/05-$props.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ On the other side, inside `MyComponent.svelte`, we can receive props with the `$
3737

3838
## Fallback values
3939

40-
Destructuring allows us to declare fallback values, which are used if the parent component does not set a given prop:
40+
Destructuring allows us to declare fallback values, which are used if the parent component does not set a given prop (or the value is `undefined`):
4141

4242
```js
4343
let { adjective = 'happy' } = $props();
@@ -219,4 +219,4 @@ This is useful for linking elements via attributes like `for` and `aria-labelled
219219
<label for="{uid}-lastname">Last Name: </label>
220220
<input id="{uid}-lastname" type="text" />
221221
</form>
222-
```
222+
```

documentation/docs/03-template-syntax/01-basic-markup.md

+2
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ A JavaScript expression can be included as text by surrounding it with curly bra
154154
{expression}
155155
```
156156

157+
Expressions that are `null` or `undefined` will be omitted; all others are [coerced to strings](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#string_coercion).
158+
157159
Curly braces can be included in a Svelte template by using their [HTML entity](https://developer.mozilla.org/docs/Glossary/Entity) strings: `&lbrace;`, `&lcub;`, or `&#123;` for `{` and `&rbrace;`, `&rcub;`, or `&#125;` for `}`.
158160

159161
If you're using a regular expression (`RegExp`) [literal notation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#literal_notation_and_constructor), you'll need to wrap it in parentheses.

0 commit comments

Comments
 (0)