Skip to content

Commit bd61e59

Browse files
Sync svelte docs (sveltejs#807)
sync svelte docs Co-authored-by: Rich-Harris <[email protected]>
1 parent db583c6 commit bd61e59

File tree

6 files changed

+26
-6
lines changed

6 files changed

+26
-6
lines changed

apps/svelte.dev/content/docs/svelte/03-template-syntax/11-bind.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ All visible elements have the following readonly bindings, measured with a `Resi
223223
</div>
224224
```
225225

226+
> [!NOTE] `display: inline` elements do not have a width or height (except for elements with 'intrinsic' dimensions, like `<img>` and `<canvas>`), and cannot be observed with a `ResizeObserver`. You will need to change the `display` style of these elements to something else, such as `inline-block`.
227+
226228
## bind:this
227229

228230
```svelte

apps/svelte.dev/content/docs/svelte/05-special-elements/05-svelte-element.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@ Svelte tries its best to infer the correct namespace from the element's surround
2929
```svelte
3030
<svelte:element this={tag} xmlns="http://www.w3.org/2000/svg" />
3131
```
32+
33+
`this` needs to be a valid DOM element tag, things like `#text` or `svelte:head` will not work.

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ Using it together with dynamic components to restrict what kinds of component ca
195195
<DynamicComponent prop="foo" />
196196
```
197197

198-
Closely related to the `Component` type is the `ComponentProps` type which extracts the properties a component expects.
198+
> [!LEGACY] In Svelte 4, components were of type `SvelteComponent`
199+
200+
To extract the properties from a component, use `ComponentProps`.
199201

200202
```ts
201203
import type { Component, ComponentProps } from 'svelte';
@@ -211,6 +213,19 @@ function withProps<TComponent extends Component<any>>(
211213
withProps(MyComponent, { foo: 'bar' });
212214
```
213215

216+
To declare that a variable expects the constructor or instance type of a component:
217+
218+
```svelte
219+
<script lang="ts">
220+
import MyComponent from './MyComponent.svelte';
221+
222+
let componentConstructor: typeof MyComponent = MyComponent;
223+
let componentInstance: MyComponent;
224+
</script>
225+
226+
<MyComponent bind:this={componentInstance} />
227+
```
228+
214229
## Enhancing built-in DOM types
215230

216231
Svelte provides a best effort of all the HTML DOM types that exist. Sometimes you may want to use experimental attributes or custom events coming from an action. In these cases, TypeScript will throw a type error, saying that it does not know these types. If it's a non-experimental standard attribute/event, this may very well be a missing typing from our [HTML typings](https://github.com/sveltejs/svelte/blob/main/packages/svelte/elements.d.ts). In that case, you are welcome to open an issue and/or a PR fixing it.

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ In Svelte 4, a `$:` statement at the top level of a component could be used to d
3636
</script>
3737
```
3838

39-
As with `$state`, nothing else changes. `double` is still the number itself, and you read it directly, without a wrapper like `.value` or `getCount()`.
39+
As with `$state`, nothing else changes. `double` is still the number itself, and you read it directly, without a wrapper like `.value` or `getDouble()`.
4040

4141
A `$:` statement could also be used to create side effects. In Svelte 5, this is achieved using the `$effect` rune:
4242

@@ -599,13 +599,14 @@ To declare that a component of a certain type is required:
599599

600600
```svelte
601601
<script lang="ts">
602-
import type { Component } from 'svelte';
602+
import type { ---SvelteComponent--- +++Component+++ } from 'svelte';
603603
import {
604604
ComponentA,
605605
ComponentB
606606
} from 'component-library';
607607
608-
let component: Component<{ foo: string }> = $state(
608+
---let component: typeof SvelteComponent<{ foo: string }>---
609+
+++let component: Component<{ foo: string }>+++ = $state(
609610
Math.random() ? ComponentA : ComponentB
610611
);
611612
</script>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ preserveComments?: boolean;
701701

702702
</div>
703703

704-
If `true`, your HTML comments will be preserved during server-side rendering. By default, they are stripped out.
704+
If `true`, your HTML comments will be preserved in the output. By default, they are stripped out.
705705

706706
</div>
707707
</div>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function blur(
4242

4343
## crossfade
4444

45-
The `crossfade` function creates a pair of [transitions](https://svelte.dev/docs#template-syntax-element-directives-transition-fn) called `send` and `receive`. When an element is 'sent', it looks for a corresponding element being 'received', and generates a transition that transforms the element to its counterpart's position and fades it out. When an element is 'received', the reverse happens. If there is no counterpart, the `fallback` transition is used.
45+
The `crossfade` function creates a pair of [transitions](https://svelte.dev/docs/svelte/transition) called `send` and `receive`. When an element is 'sent', it looks for a corresponding element being 'received', and generates a transition that transforms the element to its counterpart's position and fades it out. When an element is 'received', the reverse happens. If there is no counterpart, the `fallback` transition is used.
4646

4747
<div class="ts-block">
4848

0 commit comments

Comments
 (0)