Skip to content

Commit 06c43fb

Browse files
sync docs
1 parent 48643d6 commit 06c43fb

12 files changed

+238
-1
lines changed

apps/svelte.dev/content/docs/svelte/03-template-syntax/[email protected]

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,7 @@ function foo(+++getBar+++) {
161161
## Creating attachments programmatically
162162

163163
To add attachments to an object that will be spread onto a component or element, use [`createAttachmentKey`](svelte-attachments#createAttachmentKey).
164+
165+
## Converting actions to attachments
166+
167+
If you're using a library that only provides actions, you can convert them to attachments with [`fromAction`](svelte-attachments#fromAction), allowing you to (for example) use them with components.

apps/svelte.dev/content/docs/svelte/98-reference/.generated/client-warnings.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ function add() {
3434
}
3535
```
3636
37+
### await_reactivity_loss
38+
39+
```
40+
Detected reactivity loss
41+
```
42+
43+
TODO
44+
45+
### await_waterfall
46+
47+
```
48+
An async value (%location%) was not read immediately after it resolved. This often indicates an unnecessary waterfall, which can slow down your app.
49+
```
50+
51+
TODO
52+
3753
### binding_property_non_reactive
3854
3955
```

apps/svelte.dev/content/docs/svelte/98-reference/.generated/compile-errors.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,12 @@ Expected token %token%
480480
Expected whitespace
481481
```
482482

483+
### experimental_async
484+
485+
```
486+
Cannot use `await` in deriveds and template expressions, or at the top level of a component, unless the `experimental.async` compiler option is `true`
487+
```
488+
483489
### export_undefined
484490

485491
```
@@ -534,6 +540,12 @@ The arguments keyword cannot be used within the template or at the top level of
534540
%message%
535541
```
536542

543+
### legacy_await_invalid
544+
545+
```
546+
Cannot use `await` in deriveds and template expressions, or at the top level of a component, unless in runes mode
547+
```
548+
537549
### legacy_export_invalid
538550

539551
```

apps/svelte.dev/content/docs/svelte/98-reference/.generated/compile-warnings.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,25 @@ In some situations a selector may target an element that is not 'visible' to the
632632
</style>
633633
```
634634

635+
### element_implicitly_closed
636+
637+
```
638+
This element is implicitly closed by the following `%tag%`, which can cause an unexpected DOM structure. Add an explicit `%closing%` to avoid surprises.
639+
```
640+
641+
In HTML, some elements are implicitly closed by another element. For example, you cannot nest a `<p>` inside another `<p>`:
642+
643+
```html
644+
<!-- this HTML... -->
645+
<p><p>hello</p>
646+
647+
<!-- results in this DOM structure -->
648+
<p></p>
649+
<p>hello</p>
650+
```
651+
652+
Similarly, a parent element's closing tag will implicitly close all child elements, even if the `</` was a typo and you meant to create a _new_ element. To avoid ambiguity, it's always a good idea to have an explicit closing tag.
653+
635654
### element_invalid_self_closing_tag
636655

637656
```

apps/svelte.dev/content/docs/svelte/98-reference/.generated/shared-errors.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<!-- This file is generated by scripts/process-messages/index.js. Do not edit! -->
22

3+
### await_outside_boundary
4+
5+
```
6+
Cannot await outside a `<svelte:boundary>` with a `pending` snippet
7+
```
8+
9+
TODO
10+
311
### invalid_default_snippet
412

513
```

apps/svelte.dev/content/docs/svelte/98-reference/20-svelte.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
createEventDispatcher,
1616
createRawSnippet,
1717
flushSync,
18+
getAbortSignal,
1819
getAllContexts,
1920
getContext,
2021
hasContext,
@@ -23,6 +24,7 @@ import {
2324
onDestroy,
2425
onMount,
2526
setContext,
27+
settled,
2628
tick,
2729
unmount,
2830
untrack
@@ -291,6 +293,40 @@ function flushSync<T = void>(fn?: (() => T) | undefined): T;
291293

292294

293295

296+
## getAbortSignal
297+
298+
Returns an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) that aborts when the current [derived](/docs/svelte/$derived) or [effect](/docs/svelte/$effect) re-runs or is destroyed.
299+
300+
Must be called while a derived or effect is running.
301+
302+
```svelte
303+
<script>
304+
import { getAbortSignal } from 'svelte';
305+
306+
let { id } = $props();
307+
308+
async function getData(id) {
309+
const response = await fetch(`/items/${id}`, {
310+
signal: getAbortSignal()
311+
});
312+
313+
return await response.json();
314+
}
315+
316+
const data = $derived(await getData(id));
317+
</script>
318+
```
319+
320+
<div class="ts-block">
321+
322+
```dts
323+
function getAbortSignal(): AbortSignal;
324+
```
325+
326+
</div>
327+
328+
329+
294330
## getAllContexts
295331

296332
Retrieves the whole context map that belongs to the closest parent component.
@@ -461,6 +497,21 @@ function setContext<T>(key: any, context: T): T;
461497

462498

463499

500+
## settled
501+
502+
Returns a promise that resolves once any state changes, and asynchronous work resulting from them,
503+
have resolved and the DOM has been updated
504+
505+
<div class="ts-block">
506+
507+
```dts
508+
function settled(): Promise<void>;
509+
```
510+
511+
</div>
512+
513+
514+
464515
## tick
465516

466517
Returns a promise that resolves once any pending state changes have been applied.

apps/svelte.dev/content/docs/svelte/98-reference/21-svelte-attachments.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: svelte/attachments
77

88
```js
99
// @noErrors
10-
import { createAttachmentKey } from 'svelte/attachments';
10+
import { createAttachmentKey, fromAction } from 'svelte/attachments';
1111
```
1212

1313
## createAttachmentKey
@@ -48,6 +48,52 @@ function createAttachmentKey(): symbol;
4848

4949

5050

51+
## fromAction
52+
53+
Converts an [action](/docs/svelte/use) into an [attachment](/docs/svelte/@attach) keeping the same behavior.
54+
It's useful if you want to start using attachments on components but you have actions provided by a library.
55+
56+
Note that the second argument, if provided, must be a function that _returns_ the argument to the
57+
action function, not the argument itself.
58+
59+
```svelte
60+
<!-- with an action -->
61+
<div use:foo={bar}>...</div>
62+
63+
<!-- with an attachment -->
64+
<div {@attach fromAction(foo, () => bar)}>...</div>
65+
```
66+
67+
<div class="ts-block">
68+
69+
```dts
70+
function fromAction<
71+
E extends EventTarget,
72+
T extends unknown
73+
>(
74+
action:
75+
| Action<E, T>
76+
| ((element: E, arg: T) => void | ActionReturn<T>),
77+
fn: () => T
78+
): Attachment<E>;
79+
```
80+
81+
</div>
82+
83+
<div class="ts-block">
84+
85+
```dts
86+
function fromAction<E extends EventTarget>(
87+
action:
88+
| Action<E, void>
89+
| ((element: E) => void | ActionReturn<void>)
90+
): Attachment<E>;
91+
```
92+
93+
</div>
94+
95+
96+
5197
## Attachment
5298

5399
An [attachment](/docs/svelte/@attach) is a function that runs when an element is mounted

apps/svelte.dev/content/docs/svelte/98-reference/21-svelte-compiler.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,32 @@ warningFilter?: (warning: Warning) => boolean;
12241224
A function that gets a `Warning` as an argument and returns a boolean.
12251225
Use this to filter out warnings. Return `true` to keep the warning, `false` to discard it.
12261226

1227+
</div>
1228+
</div>
1229+
1230+
<div class="ts-block-property">
1231+
1232+
```dts
1233+
experimental?: {/*…*/}
1234+
```
1235+
1236+
<div class="ts-block-property-details">
1237+
1238+
Experimental options
1239+
1240+
<div class="ts-block-property-children"><div class="ts-block-property">
1241+
1242+
```dts
1243+
async?: boolean;
1244+
```
1245+
1246+
<div class="ts-block-property-details">
1247+
1248+
Allow `await` keyword in deriveds, template expressions, and the top level of components
1249+
1250+
</div>
1251+
</div></div>
1252+
12271253
</div>
12281254
</div></div>
12291255

apps/svelte.dev/content/docs/svelte/98-reference/30-compiler-errors.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,12 @@ Expected token %token%
485485
Expected whitespace
486486
```
487487

488+
### experimental_async
489+
490+
```
491+
Cannot use `await` in deriveds and template expressions, or at the top level of a component, unless the `experimental.async` compiler option is `true`
492+
```
493+
488494
### export_undefined
489495

490496
```
@@ -539,6 +545,12 @@ The arguments keyword cannot be used within the template or at the top level of
539545
%message%
540546
```
541547

548+
### legacy_await_invalid
549+
550+
```
551+
Cannot use `await` in deriveds and template expressions, or at the top level of a component, unless in runes mode
552+
```
553+
542554
### legacy_export_invalid
543555

544556
```

apps/svelte.dev/content/docs/svelte/98-reference/30-compiler-warnings.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,25 @@ In some situations a selector may target an element that is not 'visible' to the
653653
</style>
654654
```
655655

656+
### element_implicitly_closed
657+
658+
```
659+
This element is implicitly closed by the following `%tag%`, which can cause an unexpected DOM structure. Add an explicit `%closing%` to avoid surprises.
660+
```
661+
662+
In HTML, some elements are implicitly closed by another element. For example, you cannot nest a `<p>` inside another `<p>`:
663+
664+
```html
665+
<!-- this HTML... -->
666+
<p><p>hello</p>
667+
668+
<!-- results in this DOM structure -->
669+
<p></p>
670+
<p>hello</p>
671+
```
672+
673+
Similarly, a parent element's closing tag will implicitly close all child elements, even if the `</` was a typo and you meant to create a _new_ element. To avoid ambiguity, it's always a good idea to have an explicit closing tag.
674+
656675
### element_invalid_self_closing_tag
657676

658677
```

apps/svelte.dev/content/docs/svelte/98-reference/30-runtime-errors.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ Certain methods such as `mount` cannot be invoked while running in a server cont
184184

185185
<!-- This file is generated by scripts/process-messages/index.js. Do not edit! -->
186186

187+
### await_outside_boundary
188+
189+
```
190+
Cannot await outside a `<svelte:boundary>` with a `pending` snippet
191+
```
192+
193+
TODO
194+
187195
### invalid_default_snippet
188196

189197
```

apps/svelte.dev/content/docs/svelte/98-reference/30-runtime-warnings.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@ function add() {
4141
}
4242
```
4343
44+
### await_reactivity_loss
45+
46+
```
47+
Detected reactivity loss
48+
```
49+
50+
TODO
51+
52+
### await_waterfall
53+
54+
```
55+
An async value (%location%) was not read immediately after it resolved. This often indicates an unnecessary waterfall, which can slow down your app.
56+
```
57+
58+
TODO
59+
4460
### binding_property_non_reactive
4561
4662
```

0 commit comments

Comments
 (0)