Skip to content

Commit 63e4049

Browse files
committed
Docs: document rest in array/object destructuring in each blocks
Closes #2676
1 parent 5263354 commit 63e4049

File tree

3 files changed

+86
-78
lines changed

3 files changed

+86
-78
lines changed

site/content/docs/01-component-format.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ A `<script>` block contains JavaScript that runs when a component instance is cr
3030

3131
Svelte uses the `export` keyword to mark a variable declaration as a *property* or *prop*, which means it becomes accessible to consumers of the component:
3232

33-
```html
33+
```sv
3434
<script>
3535
// these properties can be set externally
3636
export let foo;
@@ -61,7 +61,7 @@ Update expressions (`count += 1`) and property assignments (`obj.x = y`) have th
6161

6262
Because Svelte's reactivity is based on assignments, using array methods like `.push()` and `.splice()` won't automatically trigger updates. Options for getting around this can be found in the [tutorial](tutorial/updating-arrays-and-objects).
6363

64-
```html
64+
```sv
6565
<script>
6666
let count = 0;
6767
@@ -79,7 +79,7 @@ Because Svelte's reactivity is based on assignments, using array methods like `.
7979

8080
Any top-level statement (i.e. not inside a block or a function) can be made reactive by prefixing it with the `$:` label. Reactive statements run immediately before the component updates, whenever the values that they depend on have changed.
8181

82-
```html
82+
```sv
8383
<script>
8484
export let title;
8585
@@ -98,7 +98,7 @@ Any top-level statement (i.e. not inside a block or a function) can be made reac
9898

9999
If a statement consists entirely of an assignment to an undeclared variable, Svelte will inject a `let` declaration on your behalf.
100100

101-
```html
101+
```sv
102102
<script>
103103
export let num;
104104
@@ -119,7 +119,7 @@ Note that the store must be declared at the top level of the component — not i
119119

120120
Local variables (that do not represent store values) must *not* have a `$` prefix.
121121

122-
```html
122+
```sv
123123
<script>
124124
import { writable } from 'svelte/store';
125125
@@ -142,7 +142,7 @@ You can `export` bindings from this block, and they will become exports of the c
142142

143143
You cannot `export default`, since the default export is the component itself.
144144

145-
```html
145+
```sv
146146
<script context="module">
147147
let totalComponents = 0;
148148
@@ -181,7 +181,7 @@ This works by adding a class to affected elements, which is based on a hash of t
181181

182182
To apply styles to a selector globally, use the `:global(...)` modifier.
183183

184-
```html
184+
```sv
185185
<style>
186186
:global(body) {
187187
/* this will apply to <body> */

0 commit comments

Comments
 (0)