Skip to content

Commit 712e807

Browse files
committed
Docs: document rest in array/object destructuring in each blocks
Closes #2676
1 parent 0ce8dc9 commit 712e807

File tree

3 files changed

+97
-77
lines changed

3 files changed

+97
-77
lines changed

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

+7-7
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;
@@ -58,7 +58,7 @@ Update expressions (`count += 1`) and property assignments (`obj.x = y`) have th
5858

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

61-
```html
61+
```sv
6262
<script>
6363
let count = 0;
6464
@@ -76,7 +76,7 @@ Because Svelte's reactivity is based on assignments, using array methods like `.
7676

7777
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.
7878

79-
```html
79+
```sv
8080
<script>
8181
export let title;
8282
@@ -95,7 +95,7 @@ Any top-level statement (i.e. not inside a block or a function) can be made reac
9595

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

98-
```html
98+
```sv
9999
<script>
100100
export let num;
101101
@@ -116,7 +116,7 @@ Note that the store must be declared at the top level of the component — not i
116116

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

119-
```html
119+
```sv
120120
<script>
121121
import { writable } from 'svelte/store';
122122
@@ -139,7 +139,7 @@ You can `export` bindings from this block, and they will become exports of the c
139139

140140
You cannot `export default`, since the default export is the component itself.
141141

142-
```html
142+
```sv
143143
<script context="module">
144144
let totalComponents = 0;
145145
@@ -178,7 +178,7 @@ This works by adding a class to affected elements, which is based on a hash of t
178178

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

181-
```html
181+
```sv
182182
<style>
183183
:global(body) {
184184
/* this will apply to <body> */

0 commit comments

Comments
 (0)