Skip to content

Commit eb65954

Browse files
committed
merge master
2 parents fb5ac5c + 8e85b3f commit eb65954

20 files changed

+538
-394
lines changed

documentation/docs/02-template-syntax/03-logic-blocks.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ title: Logic blocks
55
## {#if ...}
66

77
```svelte
8+
<!--- copy: false --->
89
{#if expression}...{/if}
910
```
1011

1112
```svelte
13+
<!--- copy: false --->
1214
{#if expression}...{:else if expression}...{/if}
1315
```
1416

1517
```svelte
18+
<!--- copy: false --->
1619
{#if expression}...{:else}...{/if}
1720
```
1821

@@ -41,22 +44,27 @@ Additional conditions can be added with `{:else if expression}`, optionally endi
4144
## {#each ...}
4245

4346
```svelte
47+
<!--- copy: false --->
4448
{#each expression as name}...{/each}
4549
```
4650

4751
```svelte
52+
<!--- copy: false --->
4853
{#each expression as name, index}...{/each}
4954
```
5055

5156
```svelte
57+
<!--- copy: false --->
5258
{#each expression as name (key)}...{/each}
5359
```
5460

5561
```svelte
62+
<!--- copy: false --->
5663
{#each expression as name, index (key)}...{/each}
5764
```
5865

5966
```svelte
67+
<!--- copy: false --->
6068
{#each expression as name}...{:else}...{/each}
6169
```
6270

@@ -125,18 +133,22 @@ Since Svelte 4 it is possible to iterate over iterables like `Map` or `Set`. Ite
125133
## {#await ...}
126134

127135
```svelte
136+
<!--- copy: false --->
128137
{#await expression}...{:then name}...{:catch name}...{/await}
129138
```
130139

131140
```svelte
141+
<!--- copy: false --->
132142
{#await expression}...{:then name}...{/await}
133143
```
134144

135145
```svelte
146+
<!--- copy: false --->
136147
{#await expression then name}...{/await}
137148
```
138149

139150
```svelte
151+
<!--- copy: false --->
140152
{#await expression catch name}...{/await}
141153
```
142154

@@ -186,6 +198,7 @@ Similarly, if you only want to show the error state, you can omit the `then` blo
186198
## {#key ...}
187199

188200
```svelte
201+
<!--- copy: false --->
189202
{#key expression}...{/key}
190203
```
191204

documentation/docs/02-template-syntax/04-special-tags.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: Special tags
55
## {@html ...}
66

77
```svelte
8+
<!--- copy: false --->
89
{@html expression}
910
```
1011

@@ -24,10 +25,12 @@ The expression should be valid standalone HTML — `{@html "<div>"}content{@html
2425
## {@debug ...}
2526

2627
```svelte
28+
<!--- copy: false --->
2729
{@debug}
2830
```
2931

3032
```svelte
33+
<!--- copy: false --->
3134
{@debug var1, var2, ..., varN}
3235
```
3336

@@ -65,6 +68,7 @@ The `{@debug}` tag without any arguments will insert a `debugger` statement that
6568
## {@const ...}
6669

6770
```svelte
71+
<!--- copy: false --->
6872
{@const assignment}
6973
```
7074

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

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ As well as attributes, elements can have _directives_, which control the element
77
## on:_eventname_
88

99
```svelte
10+
<!--- copy: false --->
1011
on:eventname={handler}
1112
```
1213

1314
```svelte
15+
<!--- copy: false --->
1416
on:eventname|modifiers={handler}
1517
```
1618

@@ -72,7 +74,6 @@ If the `on:` directive is used without a value, the component will _forward_ the
7274
It's possible to have multiple event listeners for the same event:
7375

7476
```svelte
75-
<!--- file: App.svelte --->
7677
<script>
7778
let counter = 0;
7879
function increment() {
@@ -91,6 +92,7 @@ It's possible to have multiple event listeners for the same event:
9192
## bind:_property_
9293

9394
```svelte
95+
<!--- copy: false --->
9496
bind:property={variable}
9597
```
9698

@@ -186,6 +188,8 @@ Elements with the `contenteditable` attribute support the following bindings:
186188

187189
There are slight differences between each of these, read more about them [here](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent#Differences_from_innerText).
188190

191+
<!-- for some reason puts the comment and html on same line -->
192+
<!-- prettier-ignore -->
189193
```svelte
190194
<div contenteditable="true" bind:innerHTML={html} />
191195
```
@@ -273,13 +277,13 @@ Block-level elements have 4 read-only bindings, measured using a technique simil
273277
## bind:group
274278

275279
```svelte
280+
<!--- copy: false --->
276281
bind:group={variable}
277282
```
278283

279284
Inputs that work together can use `bind:group`.
280285

281286
```svelte
282-
<!--- file: App.svelte --->
283287
<script>
284288
let tortilla = 'Plain';
285289
@@ -304,13 +308,13 @@ Inputs that work together can use `bind:group`.
304308
## bind:this
305309

306310
```svelte
311+
<!--- copy: false --->
307312
bind:this={dom_node}
308313
```
309314

310315
To get a reference to a DOM node, use `bind:this`.
311316

312317
```svelte
313-
<!--- file: App.svelte --->
314318
<script>
315319
import { onMount } from 'svelte';
316320
@@ -329,10 +333,12 @@ To get a reference to a DOM node, use `bind:this`.
329333
## class:_name_
330334

331335
```svelte
336+
<!--- copy: false --->
332337
class:name={value}
333338
```
334339

335340
```svelte
341+
<!--- copy: false --->
336342
class:name
337343
```
338344

@@ -393,14 +399,17 @@ When `style:` directives are combined with `style` attributes, the directives wi
393399
## use:_action_
394400

395401
```svelte
402+
<!--- copy: false --->
396403
use:action
397404
```
398405

399406
```svelte
407+
<!--- copy: false --->
400408
use:action={parameters}
401409
```
402410

403411
```ts
412+
/// copy: false
404413
// @noErrors
405414
action = (node: HTMLElement, parameters: any) => {
406415
update?: (parameters: any) => void,
@@ -411,7 +420,6 @@ action = (node: HTMLElement, parameters: any) => {
411420
Actions are functions that are called when an element is created. They can return an object with a `destroy` method that is called after the element is unmounted:
412421

413422
```svelte
414-
<!--- file: App.svelte --->
415423
<script>
416424
/** @type {import('svelte/action').Action} */
417425
function foo(node) {
@@ -433,7 +441,6 @@ An action can have a parameter. If the returned value has an `update` method, it
433441
> Don't worry about the fact that we're redeclaring the `foo` function for every component instance — Svelte will hoist any functions that don't depend on local state out of the component definition.
434442
435443
```svelte
436-
<!--- file: App.svelte --->
437444
<script>
438445
export let bar;
439446
@@ -461,30 +468,37 @@ Read more in the [`svelte/action`](/docs/svelte-action) page.
461468
## transition:_fn_
462469

463470
```svelte
471+
<!--- copy: false --->
464472
transition:fn
465473
```
466474

467475
```svelte
476+
<!--- copy: false --->
468477
transition:fn={params}
469478
```
470479

471480
```svelte
481+
<!--- copy: false --->
472482
transition:fn|global
473483
```
474484

475485
```svelte
486+
<!--- copy: false --->
476487
transition:fn|global={params}
477488
```
478489

479490
```svelte
491+
<!--- copy: false --->
480492
transition:fn|local
481493
```
482494

483495
```svelte
496+
<!--- copy: false --->
484497
transition:fn|local={params}
485498
```
486499

487500
```js
501+
/// copy: false
488502
// @noErrors
489503
transition = (node: HTMLElement, params: any, options: { direction: 'in' | 'out' | 'both' }) => {
490504
delay?: number,
@@ -544,7 +558,6 @@ The `t` argument passed to `css` is a value between `0` and `1` after the `easin
544558
The function is called repeatedly _before_ the transition begins, with different `t` and `u` arguments.
545559

546560
```svelte
547-
<!--- file: App.svelte --->
548561
<script>
549562
import { elasticOut } from 'svelte/easing';
550563
@@ -644,50 +657,62 @@ An element with transitions will dispatch the following events in addition to an
644657
## in:_fn_/out:_fn_
645658

646659
```svelte
660+
<!--- copy: false --->
647661
in:fn
648662
```
649663

650664
```svelte
665+
<!--- copy: false --->
651666
in:fn={params}
652667
```
653668

654669
```svelte
670+
<!--- copy: false --->
655671
in:fn|global
656672
```
657673

658674
```svelte
675+
<!--- copy: false --->
659676
in:fn|global={params}
660677
```
661678

662679
```svelte
680+
<!--- copy: false --->
663681
in:fn|local
664682
```
665683

666684
```svelte
685+
<!--- copy: false --->
667686
in:fn|local={params}
668687
```
669688

670689
```svelte
690+
<!--- copy: false --->
671691
out:fn
672692
```
673693

674694
```svelte
695+
<!--- copy: false --->
675696
out:fn={params}
676697
```
677698

678699
```svelte
700+
<!--- copy: false --->
679701
out:fn|global
680702
```
681703

682704
```svelte
705+
<!--- copy: false --->
683706
out:fn|global={params}
684707
```
685708

686709
```svelte
710+
<!--- copy: false --->
687711
out:fn|local
688712
```
689713

690714
```svelte
715+
<!--- copy: false --->
691716
out:fn|local={params}
692717
```
693718

@@ -704,14 +729,17 @@ Unlike with `transition:`, transitions applied with `in:` and `out:` are not bid
704729
## animate:_fn_
705730

706731
```svelte
732+
<!--- copy: false --->
707733
animate:name
708734
```
709735

710736
```svelte
737+
<!--- copy: false --->
711738
animate:name={params}
712739
```
713740

714741
```js
742+
/// copy: false
715743
// @noErrors
716744
animation = (node: HTMLElement, { from: DOMRect, to: DOMRect } , params: any) => {
717745
delay?: number,
@@ -723,6 +751,7 @@ animation = (node: HTMLElement, { from: DOMRect, to: DOMRect } , params: any) =>
723751
```
724752

725753
```ts
754+
/// copy: false
726755
// @noErrors
727756
DOMRect {
728757
bottom: number,
@@ -772,7 +801,6 @@ The function is called repeatedly _before_ the animation begins, with different
772801
<!-- TODO: Types -->
773802

774803
```svelte
775-
<!--- file: App.svelte --->
776804
<script>
777805
import { cubicOut } from 'svelte/easing';
778806
@@ -806,7 +834,6 @@ A custom animation function can also return a `tick` function, which is called _
806834
> If it's possible to use `css` instead of `tick`, do so — CSS animations can run off the main thread, preventing jank on slower devices.
807835
808836
```svelte
809-
<!--- file: App.svelte --->
810837
<script>
811838
import { cubicOut } from 'svelte/easing';
812839

0 commit comments

Comments
 (0)