Skip to content

Commit c345928

Browse files
authored
chore: tidy up, highlight deprecations in reference docs (#209)
fixes #165
1 parent a014a79 commit c345928

File tree

15 files changed

+274
-174
lines changed

15 files changed

+274
-174
lines changed

apps/svelte.dev/content/docs/svelte/04-runtime/03-lifecycle-hooks.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ If a function is returned from `onMount`, it will be called when the component i
4545
4646
## `onDestroy`
4747

48+
Schedules a callback to run immediately before the component is unmounted.
49+
50+
Out of `onMount`, `beforeUpdate`, `afterUpdate` and `onDestroy`, this is the
51+
only one that runs inside a server-side component.
52+
4853
<div class="ts-block">
4954

5055
```dts
@@ -53,6 +58,8 @@ function onDestroy(fn: () => any): void;
5358

5459
</div>
5560

61+
62+
5663
Schedules a callback to run immediately before the component is unmounted.
5764

5865
Out of `onMount`, `beforeUpdate`, `afterUpdate` and `onDestroy`, this is the only one that runs inside a server-side component.

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

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ import {
2828

2929
## afterUpdate
3030

31+
<blockquote class="tag deprecated">
32+
33+
Use `$effect` instead — see https://svelte-5-preview.vercel.app/docs/deprecations#beforeupdate-and-afterupdate
34+
35+
</blockquote>
36+
3137
Schedules a callback to run immediately after the component has been updated.
3238

3339
The first time the callback runs will be after the initial `onMount`.
@@ -42,8 +48,16 @@ function afterUpdate(fn: () => void): void;
4248

4349
</div>
4450

51+
52+
4553
## beforeUpdate
4654

55+
<blockquote class="tag deprecated">
56+
57+
Use `$effect.pre` instead — see https://svelte-5-preview.vercel.app/docs/deprecations#beforeupdate-and-afterupdate
58+
59+
</blockquote>
60+
4761
Schedules a callback to run immediately before the component is updated after any state change.
4862

4963
The first time the callback runs will be before the initial `onMount`.
@@ -58,8 +72,16 @@ function beforeUpdate(fn: () => void): void;
5872

5973
</div>
6074

75+
76+
6177
## createEventDispatcher
6278

79+
<blockquote class="tag deprecated">
80+
81+
Use callback props and/or the `$host()` rune instead — see https://svelte-5-preview.vercel.app/docs/deprecations#createeventdispatcher
82+
83+
</blockquote>
84+
6385
Creates an event dispatcher that can be used to dispatch [component events](https://svelte.dev/docs#template-syntax-component-directives-on-eventname).
6486
Event dispatchers are functions that can take two arguments: `name` and `detail`.
6587

@@ -88,6 +110,8 @@ function createEventDispatcher<
88110

89111
</div>
90112

113+
114+
91115
## createRawSnippet
92116

93117
Create a snippet programmatically
@@ -105,6 +129,8 @@ function createRawSnippet<Params extends unknown[]>(
105129

106130
</div>
107131

132+
133+
108134
## flushSync
109135

110136
Synchronously flushes any pending state changes and those that result from it.
@@ -117,6 +143,8 @@ function flushSync(fn?: (() => void) | undefined): void;
117143

118144
</div>
119145

146+
147+
120148
## getAllContexts
121149

122150
Retrieves the whole context map that belongs to the closest parent component.
@@ -133,6 +161,8 @@ function getAllContexts<
133161

134162
</div>
135163

164+
165+
136166
## getContext
137167

138168
Retrieves the context that belongs to the closest parent component with the specified `key`.
@@ -146,6 +176,8 @@ function getContext<T>(key: any): T;
146176

147177
</div>
148178

179+
180+
149181
## hasContext
150182

151183
Checks whether a given `key` has been set in the context of a parent component.
@@ -159,6 +191,8 @@ function hasContext(key: any): boolean;
159191

160192
</div>
161193

194+
195+
162196
## hydrate
163197

164198
Hydrates a component on the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component
@@ -195,6 +229,8 @@ function hydrate<
195229

196230
</div>
197231

232+
233+
198234
## mount
199235

200236
Mounts a component to the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component.
@@ -232,6 +268,8 @@ function mount<
232268

233269
</div>
234270

271+
272+
235273
## onDestroy
236274

237275
Schedules a callback to run immediately before the component is unmounted.
@@ -247,6 +285,8 @@ function onDestroy(fn: () => any): void;
247285

248286
</div>
249287

288+
289+
250290
## onMount
251291

252292
The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM.
@@ -270,6 +310,8 @@ function onMount<T>(
270310

271311
</div>
272312

313+
314+
273315
## setContext
274316

275317
Associates an arbitrary `context` object with the current component and the specified `key`
@@ -286,6 +328,8 @@ function setContext<T>(key: any, context: T): T;
286328

287329
</div>
288330

331+
332+
289333
## tick
290334

291335
Returns a promise that resolves once any pending state changes have been applied.
@@ -298,6 +342,8 @@ function tick(): Promise<void>;
298342

299343
</div>
300344

345+
346+
301347
## unmount
302348

303349
Unmounts a component that was previously mounted using `mount` or `hydrate`.
@@ -310,6 +356,8 @@ function unmount(component: Record<string, any>): void;
310356

311357
</div>
312358

359+
360+
313361
## untrack
314362

315363
Use `untrack` to prevent something from being treated as an `$effect`/`$derived` dependency.
@@ -324,6 +372,8 @@ function untrack<T>(fn: () => T): T;
324372

325373
</div>
326374

375+
376+
327377
## Component
328378

329379
Can be used to create strongly typed Svelte components.
@@ -403,8 +453,7 @@ element?: typeof HTMLElement;
403453
The custom element version of the component. Only present if compiled with the `customElement` compiler option
404454

405455
</div>
406-
</div>
407-
</div>
456+
</div></div>
408457

409458
## ComponentConstructorOptions
410459

@@ -504,8 +553,7 @@ $$inline?: boolean;
504553
```
505554

506555
<div class="ts-block-property-details"></div>
507-
</div>
508-
</div>
556+
</div></div>
509557

510558
## ComponentEvents
511559

@@ -524,7 +572,6 @@ type ComponentEvents<Comp extends SvelteComponent> =
524572
: never;
525573
```
526574

527-
528575
</div>
529576

530577
## ComponentInternals
@@ -537,7 +584,6 @@ Internal implementation details that vary between environments
537584
type ComponentInternals = Branded<{}, 'ComponentInternals'>;
538585
```
539586

540-
541587
</div>
542588

543589
## ComponentProps
@@ -582,7 +628,6 @@ type ComponentProps<
582628
: never;
583629
```
584630

585-
586631
</div>
587632

588633
## ComponentType
@@ -610,7 +655,6 @@ type ComponentType<
610655
};
611656
```
612657

613-
614658
</div>
615659

616660
## EventDispatcher
@@ -636,8 +680,7 @@ interface EventDispatcher<
636680
```
637681

638682
<div class="ts-block-property-details"></div>
639-
</div>
640-
</div>
683+
</div></div>
641684

642685
## Snippet
643686

@@ -670,8 +713,7 @@ interface Snippet<Parameters extends unknown[] = []> {/*…*/}
670713
```
671714

672715
<div class="ts-block-property-details"></div>
673-
</div>
674-
</div>
716+
</div></div>
675717

676718
## SvelteComponent
677719

@@ -789,8 +831,7 @@ for more info.
789831
</div>
790832

791833
</div>
792-
</div>
793-
</div>
834+
</div></div>
794835

795836
## SvelteComponentTyped
796837

@@ -810,7 +851,6 @@ class SvelteComponentTyped<
810851
> extends SvelteComponent<Props, Events, Slots> {}
811852
```
812853

813-
814854
</div>
815855

816856

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ interface Action<
4242
```
4343

4444
<div class="ts-block-property-details"></div>
45-
</div>
46-
</div>
45+
</div></div>
4746

4847
## ActionReturn
4948

@@ -100,7 +99,6 @@ destroy?: () => void;
10099
```
101100

102101
<div class="ts-block-property-details"></div>
103-
</div>
104-
</div>
102+
</div></div>
105103

106104

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ function flip(
3232

3333
</div>
3434

35+
36+
3537
## AnimationConfig
3638

3739
<div class="ts-block">
@@ -83,8 +85,7 @@ tick?: (t: number, u: number) => void;
8385
```
8486

8587
<div class="ts-block-property-details"></div>
86-
</div>
87-
</div>
88+
</div></div>
8889

8990
## FlipParams
9091

@@ -119,7 +120,6 @@ easing?: (t: number) => number;
119120
```
120121

121122
<div class="ts-block-property-details"></div>
122-
</div>
123-
</div>
123+
</div></div>
124124

125125

0 commit comments

Comments
 (0)