Skip to content

Commit

Permalink
Sync svelte docs (#1104)
Browse files Browse the repository at this point in the history
sync svelte docs

Co-authored-by: Rich-Harris <[email protected]>
  • Loading branch information
github-actions[bot] and Rich-Harris authored Jan 20, 2025
1 parent 78f401b commit d160b19
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ The `{@const ...}` tag defines a local constant.
{/each}
```

`{@const}` is only allowed as an immediate child of a block — `{#if ...}`, `{#each ...}`, `{#snippet ...}` and so on — or a `<Component />`.
`{@const}` is only allowed as an immediate child of a block — `{#if ...}`, `{#each ...}`, `{#snippet ...}` and so on — a `<Component />` or a `<svelte:boundary`.
12 changes: 12 additions & 0 deletions apps/svelte.dev/content/docs/svelte/03-template-syntax/18-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ The user of this component has the same flexibility to use a mixture of objects,
</Button>
```

Svelte also exposes the `ClassValue` type, which is the type of value that the `class` attribute on elements accept. This is useful if you want to use a type-safe class name in component props:

```svelte
<script lang="ts">
import type { ClassValue } from 'svelte/elements';
const props: { class: ClassValue } = $props();
</script>
<div class={['original', props.class]}>...</div>
```

## The `class:` directive

Prior to Svelte 5.16, the `class:` directive was the most convenient way to set classes on elements conditionally.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Cyclical dependency detected: %cycle%
### const_tag_invalid_placement

```
`{@const}` must be the immediate child of `{#snippet}`, `{#if}`, `{:else if}`, `{:else}`, `{#each}`, `{:then}`, `{:catch}`, `<svelte:fragment>` or `<Component>`
`{@const}` must be the immediate child of `{#snippet}`, `{#if}`, `{:else if}`, `{:else}`, `{#each}`, `{:then}`, `{:catch}`, `<svelte:fragment>`, `<svelte:boundary` or `<Component>`
```

### constant_assignment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,6 @@ set target(v: T);
get target(): T;
```

<div class="ts-block-property-details"></div>
</div>

<div class="ts-block-property">

```dts
#private;
```

<div class="ts-block-property-details"></div>
</div></div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,6 @@ class SvelteDate extends Date {/*…*/}
constructor(...params: any[]);
```

<div class="ts-block-property-details"></div>
</div>

<div class="ts-block-property">

```dts
#private;
```

<div class="ts-block-property-details"></div>
</div></div>

Expand Down Expand Up @@ -138,15 +129,6 @@ constructor(value?: Iterable<readonly [K, V]> | null | undefined);
set(key: K, value: V): this;
```

<div class="ts-block-property-details"></div>
</div>

<div class="ts-block-property">

```dts
#private;
```

<div class="ts-block-property-details"></div>
</div></div>

Expand Down Expand Up @@ -175,15 +157,6 @@ constructor(value?: Iterable<T> | null | undefined);
add(value: T): this;
```

<div class="ts-block-property-details"></div>
</div>

<div class="ts-block-property">

```dts
#private;
```

<div class="ts-block-property-details"></div>
</div></div>

Expand All @@ -203,15 +176,6 @@ class SvelteURL extends URL {/*…*/}
get searchParams(): SvelteURLSearchParams;
```

<div class="ts-block-property-details"></div>
</div>

<div class="ts-block-property">

```dts
#private;
```

<div class="ts-block-property-details"></div>
</div></div>

Expand All @@ -231,15 +195,6 @@ class SvelteURLSearchParams extends URLSearchParams {/*…*/}
[REPLACE](params: URLSearchParams): void;
```

<div class="ts-block-property-details"></div>
</div>

<div class="ts-block-property">

```dts
#private;
```

<div class="ts-block-property-details"></div>
</div></div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Cyclical dependency detected: %cycle%
### const_tag_invalid_placement

```
`{@const}` must be the immediate child of `{#snippet}`, `{#if}`, `{:else if}`, `{:else}`, `{#each}`, `{:then}`, `{:catch}`, `<svelte:fragment>` or `<Component>`
`{@const}` must be the immediate child of `{#snippet}`, `{#if}`, `{:else if}`, `{:else}`, `{#each}`, `{:then}`, `{:catch}`, `<svelte:fragment>`, `<svelte:boundary` or `<Component>`
```

### constant_assignment
Expand Down

0 comments on commit d160b19

Please sign in to comment.