Skip to content

Commit e80d79d

Browse files
Sync svelte docs (#826)
sync svelte docs Co-authored-by: Rich-Harris <1162160+Rich-Harris@users.noreply.github.com>
1 parent d401d8c commit e80d79d

File tree

8 files changed

+60
-7
lines changed

8 files changed

+60
-7
lines changed

apps/svelte.dev/content/docs/svelte/03-template-syntax/06-snippet.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Any content inside the component tags that is _not_ a snippet declaration implic
169169

170170
```svelte
171171
<!--- file: App.svelte --->
172-
<Button>click me<Button>
172+
<Button>click me</Button>
173173
```
174174

175175
```svelte

apps/svelte.dev/content/docs/svelte/06-runtime/01-stores.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,28 @@ Prior to Svelte 5, stores were the go-to solution for creating cross-component r
3838
- when extracting logic, it's better to take advantage of runes' universal reactivity: You can use runes outside the top level of components and even place them into JavaScript or TypeScript files (using a `.svelte.js` or `.svelte.ts` file ending)
3939
- when creating shared state, you can create a `$state` object containing the values you need and then manipulate said state
4040

41+
```ts
42+
/// file: state.svelte.js
43+
export const userState = $state({
44+
name: 'name',
45+
/* ... */
46+
});
47+
```
48+
49+
```svelte
50+
<!--- file: App.svelte --->
51+
<script>
52+
import { userState } from './state.svelte';
53+
</script>
54+
55+
<p>User name: {userState.name}</p>
56+
<button onclick={() => {
57+
userState.name = 'new name';
58+
}}>
59+
change name
60+
</button>
61+
```
62+
4163
Stores are still a good solution when you have complex asynchronous data streams or it's important to have more manual control over updating values or listening to changes. If you're familiar with RxJs and want to reuse that knowledge, the `$` also comes in handy for you.
4264

4365
## svelte/store

apps/svelte.dev/content/docs/svelte/07-misc/02-testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ When writing component tests that involve two-way bindings, context or snippet p
197197

198198
E2E (short for 'end to end') tests allow you to test your full application through the eyes of the user. This section uses [Playwright](https://playwright.dev/) as an example, but you can also use other solutions like [Cypress](https://www.cypress.io/) or [NightwatchJS](https://nightwatchjs.org/).
199199

200-
To get start with Playwright, either let you guide by [their VS Code extension](https://playwright.dev/docs/getting-started-vscode), or install it from the command line using `npm init playwright`. It is also part of the setup CLI when you run `npx sv create`.
200+
To get started with Playwright, either install it via [the VS Code extension](https://playwright.dev/docs/getting-started-vscode), or install it from the command line using `npm init playwright`. It is also part of the setup CLI when you run `npx sv create`.
201201

202202
After you've done that, you should have a `tests` folder and a Playwright config. You may need to adjust that config to tell Playwright what to do before running the tests - mainly starting your application at a certain port:
203203

apps/svelte.dev/content/docs/svelte/07-misc/03-typescript.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ In case you're writing a component that wraps a native element, you may want to
142142
</script>
143143
144144
<button {...rest}>
145-
{@render children()}
145+
{@render children?.()}
146146
</button>
147147
```
148148

@@ -156,7 +156,7 @@ Not all elements have a dedicated type definition. For those without one, use `S
156156
</script>
157157
158158
<div {...rest}>
159-
{@render children()}
159+
{@render children?.()}
160160
</div>
161161
```
162162

apps/svelte.dev/content/docs/svelte/07-misc/07-v5-migration-guide.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,11 @@ This function is deprecated in Svelte 5. Instead, components should accept _call
169169
170170
<Pump
171171
---on:---inflate={(power) => {
172-
size += power---.details---;
172+
size += power---.detail---;
173173
if (size > 75) burst = true;
174174
}}
175175
---on:---deflate={(power) => {
176-
if (size > 0) size -= power---.details---;
176+
if (size > 0) size -= power---.detail---;
177177
}}
178178
/>
179179
@@ -317,7 +317,7 @@ When spreading props, local event handlers must go _after_ the spread, or they r
317317
> - import the function
318318
> - call the function to get a dispatch function
319319
> - call said dispatch function with a string and possibly a payload
320-
> - retrieve said payload on the other end through a `.details` property, because the event itself was always a `CustomEvent`
320+
> - retrieve said payload on the other end through a `.detail` property, because the event itself was always a `CustomEvent`
321321
>
322322
> It was always possible to use component callback props, but because you had to listen to DOM events using `on:`, it made sense to use `createEventDispatcher` for component events due to syntactical consistency. Now that we have event attributes (`onclick`), it's the other way around: Callback props are now the more sensible thing to do.
323323
>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,12 @@ Expected whitespace
412412
`$host()` can only be used inside custom element component instances
413413
```
414414

415+
### illegal_element_attribute
416+
417+
```
418+
`<%name%>` does not support non-event attributes or spread attributes
419+
```
420+
415421
### import_svelte_internal_forbidden
416422

417423
```

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,4 +281,23 @@ function trusted(
281281

282282

283283

284+
## LegacyComponentType
285+
286+
Support using the component as both a class and function during the transition period
287+
288+
<div class="ts-block">
289+
290+
```dts
291+
type LegacyComponentType = {
292+
new (o: ComponentConstructorOptions): SvelteComponent;
293+
(
294+
...args: Parameters<Component<Record<string, any>>>
295+
): ReturnType<
296+
Component<Record<string, any>, Record<string, any>>
297+
>;
298+
};
299+
```
300+
301+
</div>
302+
284303

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,12 @@ Expected whitespace
416416
`$host()` can only be used inside custom element component instances
417417
```
418418

419+
### illegal_element_attribute
420+
421+
```
422+
`<%name%>` does not support non-event attributes or spread attributes
423+
```
424+
419425
### import_svelte_internal_forbidden
420426

421427
```

0 commit comments

Comments
 (0)