Skip to content

Commit c1f14c1

Browse files
committed
update docs
1 parent 4c3c658 commit c1f14c1

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

documentation/docs/03-template-syntax/12-bind.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ In the case of readonly bindings like [dimension bindings](#Dimensions), the `ge
4040
> [!NOTE]
4141
> Function bindings are available in Svelte 5.9.0 and newer.
4242
43+
If you already have a tuple [get, set] or an object with `get` and/or `set` functions, you can use the spread syntax to bind them directly, instead of destructuring them beforehand.
44+
This is especially handy when using helpers that return getter/setter pairs.
45+
46+
```svelte
47+
<script>
48+
function bindLowerCase(value) {
49+
return [
50+
() => value.toLowerCase(),
51+
(v) => value = v.toLowerCase()
52+
];
53+
}
54+
</script>
55+
56+
<input bind:value={...bindLowerCase(value)} />
57+
```
58+
4359
## `<input bind:value>`
4460

4561
A `bind:value` directive on an `<input>` element binds the input's `value` property:

documentation/docs/98-reference/.generated/compile-errors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Cannot `bind:group` to a snippet parameter
9393
### bind_invalid_expression
9494

9595
```
96-
Can only bind to an Identifier or MemberExpression or a `{get, set}` pair
96+
Can only bind to an Identifier, a MemberExpression, a SpreadElement, or a `{get, set}` pair
9797
```
9898

9999
### bind_invalid_name

0 commit comments

Comments
 (0)