Skip to content

Commit 36137e0

Browse files
committed
docs: tweaks
1 parent 363f4a0 commit 36137e0

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

documentation/docs/02-template-syntax/06-transitions-and-animations.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ The `t` argument passed to `css` is a value between `0` and `1` after the `easin
102102
The function is called repeatedly _before_ the transition begins, with different `t` and `u` arguments.
103103

104104
```svelte
105+
<!--- file: App.svelte --->
105106
<script>
106107
import { elasticOut } from 'svelte/easing';
107108
@@ -345,6 +346,7 @@ The function is called repeatedly _before_ the animation begins, with different
345346
<!-- TODO: Types -->
346347

347348
```svelte
349+
<!--- file: App.svelte --->
348350
<script>
349351
import { cubicOut } from 'svelte/easing';
350352
@@ -378,6 +380,7 @@ A custom animation function can also return a `tick` function, which is called _
378380
> 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.
379381
380382
```svelte
383+
<!--- file: App.svelte --->
381384
<script>
382385
import { cubicOut } from 'svelte/easing';
383386

documentation/docs/02-template-syntax/09-special-elements.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ It cannot appear at the top level of your markup; it must be inside an if or eac
1414

1515
```svelte
1616
<script>
17-
/** @type {number} */
18-
export let count;
17+
let { count } = $props();
1918
</script>
2019
2120
{#if count > 0}
@@ -56,12 +55,12 @@ If `this` is the name of a [void element](https://developer.mozilla.org/en-US/do
5655

5756
```svelte
5857
<script>
59-
let tag = 'div';
58+
let { handler } = $props();
6059
61-
export let handler;
60+
let tag = $state('div');
6261
</script>
6362
64-
<svelte:element this={tag} on:click={handler}>Foo</svelte:element>
63+
<svelte:element this={tag} onclick={handler}>Foo</svelte:element>
6564
```
6665

6766
Svelte tries its best to infer the correct namespace from the element's surroundings, but it's not always possible. You can make it explicit with an `xmlns` attribute:
@@ -73,7 +72,7 @@ Svelte tries its best to infer the correct namespace from the element's surround
7372
## `<svelte:window>`
7473

7574
```svelte
76-
<svelte:window on:event={handler} />
75+
<svelte:window onevent={handler} />
7776
```
7877

7978
```svelte
@@ -86,13 +85,12 @@ Unlike `<svelte:self>`, this element may only appear at the top level of your co
8685

8786
```svelte
8887
<script>
89-
/** @param {KeyboardEvent} event */
9088
function handleKeydown(event) {
9189
alert(`pressed the ${event.key} key`);
9290
}
9391
</script>
9492
95-
<svelte:window on:keydown={handleKeydown} />
93+
<svelte:window onkeydown={handleKeydown} />
9694
```
9795

9896
You can also bind to the following properties:
@@ -117,7 +115,7 @@ All except `scrollX` and `scrollY` are readonly.
117115
## `<svelte:document>`
118116

119117
```svelte
120-
<svelte:document on:event={handler} />
118+
<svelte:document onevent={handler} />
121119
```
122120

123121
```svelte
@@ -129,7 +127,7 @@ Similarly to `<svelte:window>`, this element allows you to add listeners to even
129127
As with `<svelte:window>`, this element may only appear the top level of your component and must never be inside a block or element.
130128

131129
```svelte
132-
<svelte:document on:visibilitychange={handleVisibilityChange} use:someAction />
130+
<svelte:document onvisibilitychange={handleVisibilityChange} use:someAction />
133131
```
134132

135133
You can also bind to the following properties:
@@ -144,15 +142,15 @@ All are readonly.
144142
## `<svelte:body>`
145143

146144
```svelte
147-
<svelte:body on:event={handler} />
145+
<svelte:body onevent={handler} />
148146
```
149147

150148
Similarly to `<svelte:window>`, this element allows you to add listeners to events on `document.body`, such as `mouseenter` and `mouseleave`, which don't fire on `window`. It also lets you use [actions](/docs/element-directives#use-action) on the `<body>` element.
151149

152150
As with `<svelte:window>` and `<svelte:document>`, this element may only appear the top level of your component and must never be inside a block or element.
153151

154152
```svelte
155-
<svelte:body on:mouseenter={handleMouseenter} on:mouseleave={handleMouseleave} use:someAction />
153+
<svelte:body onmouseenter={handleMouseenter} onmouseleave={handleMouseleave} use:someAction />
156154
```
157155

158156
## `<svelte:head>`

documentation/docs/05-misc/03-typescript.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Components can declare a generic relationship between their properties. One exam
118118
select: Item;
119119
}
120120
121-
let { items, select } = $props();
121+
let { items, select }: Props = $props();
122122
</script>
123123
124124
{#each items as item}
@@ -210,8 +210,8 @@ declare namespace svelteHTML {
210210
}
211211
// enhance attributes
212212
interface HTMLAttributes<T> {
213-
// If you want to use on:beforeinstallprompt
214-
'on:beforeinstallprompt'?: (event: any) => any;
213+
// If you want to use the beforeinstallprompt event
214+
'onbeforeinstallprompt'?: (event: any) => any;
215215
// If you want to use myCustomAttribute={..} (note: all lowercase)
216216
mycustomattribute?: any; // You can replace any with something more specific if you like
217217
}

0 commit comments

Comments
 (0)