Skip to content

Commit 96b583e

Browse files
authored
Merge branch 'main' into repl-add-reset-btn
2 parents f3a8193 + d3ff314 commit 96b583e

File tree

130 files changed

+432
-538
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+432
-538
lines changed

apps/svelte.dev/content/docs/cli/20-commands/10-sv-create.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,19 @@ Prevent typechecking from being added. Not recommended!
3636

3737
Run the command without the interactive add-ons prompt
3838

39+
### `--install <package-manager>`
40+
41+
Installs dependencies with a specified package manager:
42+
43+
- `npm`
44+
- `pnpm`
45+
- `yarn`
46+
- `bun`
47+
- `deno`
48+
3949
### `--no-install`
4050

41-
Skip dependency installation
51+
Prevents installing dependencies.
4252

4353
<!-- ## Programmatic interface
4454

apps/svelte.dev/content/docs/cli/20-commands/20-sv-add.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ You can select multiple space-separated add-ons from [the list below](#Official-
2121

2222
- `-C`, `--cwd` — path to the root of your Svelte(Kit) project
2323
- `--no-preconditions` — skip checking preconditions <!-- TODO what does this mean? -->
24-
- `--no-install` — skip dependency installation
24+
- `--install` — installs dependencies with a specified package manager
25+
- `--no-install` — prevents installing dependencies
2526

2627
## Official add-ons
2728

apps/svelte.dev/content/docs/kit/10-getting-started/30-project-structure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ The `src` directory contains the meat of your project. Everything except `src/ro
5656
- `hooks.server.js` contains your server [hooks](hooks)
5757
- `service-worker.js` contains your [service worker](service-workers)
5858

59-
(Whether the project contains `.js` or `.ts` files depends on whether you opt to use TypeScript when you create your project. You can switch between JavaScript and TypeScript in the documentation using the toggle at the bottom of this page.)
59+
(Whether the project contains `.js` or `.ts` files depends on whether you opt to use TypeScript when you create your project.)
6060

6161
If you added [Vitest](https://vitest.dev) when you set up your project, your unit tests will live in the `src` directory with a `.test.js` extension.
6262

apps/svelte.dev/content/docs/svelte/02-runes/05-$props.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ On the other side, inside `MyComponent.svelte`, we can receive props with the `$
3838

3939
## Fallback values
4040

41-
Destructuring allows us to declare fallback values, which are used if the parent component does not set a given prop:
41+
Destructuring allows us to declare fallback values, which are used if the parent component does not set a given prop (or the value is `undefined`):
4242

4343
```js
4444
let { adjective = 'happy' } = $props();
@@ -220,4 +220,4 @@ This is useful for linking elements via attributes like `for` and `aria-labelled
220220
<label for="{uid}-lastname">Last Name: </label>
221221
<input id="{uid}-lastname" type="text" />
222222
</form>
223-
```
223+
```

apps/svelte.dev/content/docs/svelte/03-template-syntax/01-basic-markup.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ A JavaScript expression can be included as text by surrounding it with curly bra
155155
{expression}
156156
```
157157

158+
Expressions that are `null` or `undefined` will be omitted; all others are [coerced to strings](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#string_coercion).
159+
158160
Curly braces can be included in a Svelte template by using their [HTML entity](https://developer.mozilla.org/docs/Glossary/Entity) strings: `&lbrace;`, `&lcub;`, or `&#123;` for `{` and `&rbrace;`, `&rcub;`, or `&#125;` for `}`.
159161

160162
If you're using a regular expression (`RegExp`) [literal notation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#literal_notation_and_constructor), you'll need to wrap it in parentheses.

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ Snippets can reference themselves and each other ([demo](/playground/untitled#H4
113113

114114
## Passing snippets to components
115115

116+
### Explicit props
117+
116118
Within the template, snippets are values just like any other. As such, they can be passed to components as props ([demo](/playground/untitled#H4sIAAAAAAAAE3VS247aMBD9lZGpBGwDASRegonaPvQL2qdlH5zYEKvBNvbQLbL875VzAcKyj3PmzJnLGU8UOwqSkd8KJdaCk4TsZS0cyV49wYuJuQiQpGd-N2bu_ooaI1YwJ57hpVYoFDqSEepKKw3mO7VDeTTaIvxiRS1gb_URxvO0ibrS8WanIrHUyiHs7Vmigy28RmyHHmKvDMbMmFq4cQInvGSwTsBYWYoMVhCSB2rBFFPsyl0uruTlR3JZCWvlTXl1Yy_mawiR_rbZKZrellJ-5JQ0RiBUgnFhJ9OGR7HKmwVoilXeIye8DOJGfYCgRlZ3iE876TBsZPX7hPdteO75PC4QaIo8vwNPePmANQ2fMeEFHrLD7rR1jTNkW986E8C3KwfwVr8HSHOSEBT_kGRozyIkn_zQveXDL3rIfPJHtUDwzShJd_Qk3gQCbOGLsdq4yfTRJopRuin3I7nv6kL7ARRjmLdBDG3uv1mhuLA3V2mKtqNEf_oCn8p9aN-WYqH5peP4kWBl1UwJzAEPT9U7K--0fRrrWnPTXpCm1_EVdXjpNmlA8G1hPPyM1fKgMqjFHjctXGjLhZ05w0qpDhksGrybuNEHtJnCalZWsuaTlfq6nPaaBSv_HKw-K57BjzOiVj9ZKQYKzQjZodYFqydYTRN4gPhVzTDO2xnma3HsVWjaLjT8nbfwHy7Q5f2dBAAA)):
117119

118120
```svelte
@@ -145,6 +147,8 @@ Within the template, snippets are values just like any other. As such, they can
145147

146148
Think about it like passing content instead of data to a component. The concept is similar to slots in web components.
147149

150+
### Implicit props
151+
148152
As an authoring convenience, snippets declared directly _inside_ a component implicitly become props _on_ the component ([demo](/playground/untitled#H4sIAAAAAAAAE3VSTa_aMBD8Kyu_SkAbCA-JSzBR20N_QXt6vIMTO8SqsY29tI2s_PcqTiB8vaPHs7MzuxuIZgdBMvJLo0QlOElIJZXwJHsLBBvb_XUASc7Mb9Yu_B-hsMMK5sUzvDQahUZPMkJ96aTFfKd3KA_WOISfrFACKmcOMFmk8TWUTjY73RFLoz1C5U4SPWzhrcN2GKDrlcGEWauEnyRwxCaDdQLWyVJksII2uaMWTDPNLtzX5YX8-kgua-GcHJVXI3u5WEPb0d83O03TMZSmfRzOkG1Db7mNacOL19JagVALxoWbztq-H8U6j0SaYp2P2BGbOyQ2v8PQIFMXLKRDk177pq0zf6d8bMrzwBdd0pamyPMb-IjNEzS2f86Gz_Dwf-2F9nvNSUJQ_EOSoTuJNvngqK5v4Pas7n4-OCwlEEJcQTIMO-nSQwtb-GSdsX46e9gbRoP9yGQ11I0rEuycunu6PHx1QnPhxm3SFN15MOlYEFJZtf0dUywMbwZOeBGsrKNLYB54-1R9WNqVdki7usim6VmQphf7mnpshiQRhNAXdoOfMyX3OgMlKtz0cGEcF27uLSul3mewjPjgOOoDukxjPS9rqfh0pb-8zs6aBSt_7505aZ7B9xOi0T9YKW4UooVsr0zB1BTrWQJ3EL-oWcZ572GxFoezCk37QLe3897-B2i2U62uBAAA)):
149153

150154
```svelte
@@ -166,6 +170,8 @@ As an authoring convenience, snippets declared directly _inside_ a component imp
166170
</Table>
167171
```
168172

173+
### Implicit `children` snippet
174+
169175
Any content inside the component tags that is _not_ a snippet declaration implicitly becomes part of the `children` snippet ([demo](/playground/untitled#H4sIAAAAAAAAE3WOQQrCMBBFrzIMggql3ddY1Du4si5sOmIwnYRkFKX07lKqglqX8_7_w2uRDw1hjlsWI5ZqTPBoLEXMdy3K3fdZDzB5Ndfep_FKVnpWHSKNce1YiCVijirqYLwUJQOYxrsgsLmIOIZjcA1M02w4n-PpomSVvTclqyEutDX6DA2pZ7_ABIVugrmEC3XJH92P55_G39GodCmWBFrQJ2PrQAwdLGHig_NxNv9xrQa1dhWIawrv1Wzeqawa8953D-8QOmaEAQAA)):
170176

171177
```svelte
@@ -185,6 +191,8 @@ Any content inside the component tags that is _not_ a snippet declaration implic
185191

186192
> [!NOTE] Note that you cannot have a prop called `children` if you also have content inside the component — for this reason, you should avoid having props with that name
187193
194+
### Optional snippet props
195+
188196
You can declare snippet props as being optional. You can either use optional chaining to not render anything if the snippet isn't set...
189197

190198
```svelte

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,31 @@ A top-level `:global {...}` block can only contain rules, not declarations
235235
### css_global_block_invalid_list
236236

237237
```
238-
A `:global` selector cannot be part of a selector list with more than one item
238+
A `:global` selector cannot be part of a selector list with entries that don't contain `:global`
239+
```
240+
241+
The following CSS is invalid:
242+
243+
```css
244+
:global, x {
245+
y {
246+
color: red;
247+
}
248+
}
249+
```
250+
251+
This is mixing a `:global` block, which means "everything in here is unscoped", with a scoped selector (`x` in this case). As a result it's not possible to transform the inner selector (`y` in this case) into something that satisfies both requirements. You therefore have to split this up into two selectors:
252+
253+
```css
254+
:global {
255+
y {
256+
color: red;
257+
}
258+
}
259+
260+
x y {
261+
color: red;
262+
}
239263
```
240264

241265
### css_global_block_invalid_modifier

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,43 @@ Certain lifecycle methods can only be used during component initialisation. To f
6060
<button onclick={handleClick}>click me</button>
6161
```
6262

63+
### snippet_without_render_tag
64+
65+
```
66+
Attempted to render a snippet without a `{@render}` block. This would cause the snippet code to be stringified instead of its content being rendered to the DOM. To fix this, change `{snippet}` to `{@render snippet()}`.
67+
```
68+
69+
A component throwing this error will look something like this (`children` is not being rendered):
70+
71+
```svelte
72+
<script>
73+
let { children } = $props();
74+
</script>
75+
76+
{children}
77+
```
78+
79+
...or like this (a parent component is passing a snippet where a non-snippet value is expected):
80+
81+
```svelte
82+
<!--- file: Parent.svelte --->
83+
<ChildComponent>
84+
{#snippet label()}
85+
<span>Hi!</span>
86+
{/snippet}
87+
</ChildComponent>
88+
```
89+
90+
```svelte
91+
<!--- file: Child.svelte --->
92+
<script>
93+
let { label } = $props();
94+
</script>
95+
96+
<!-- This component doesn't expect a snippet, but the parent provided one -->
97+
<p>{label}</p>
98+
```
99+
63100
### store_invalid_shape
64101

65102
```

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,31 @@ A top-level `:global {...}` block can only contain rules, not declarations
240240
### css_global_block_invalid_list
241241

242242
```
243-
A `:global` selector cannot be part of a selector list with more than one item
243+
A `:global` selector cannot be part of a selector list with entries that don't contain `:global`
244+
```
245+
246+
The following CSS is invalid:
247+
248+
```css
249+
:global, x {
250+
y {
251+
color: red;
252+
}
253+
}
254+
```
255+
256+
This is mixing a `:global` block, which means "everything in here is unscoped", with a scoped selector (`x` in this case). As a result it's not possible to transform the inner selector (`y` in this case) into something that satisfies both requirements. You therefore have to split this up into two selectors:
257+
258+
```css
259+
:global {
260+
y {
261+
color: red;
262+
}
263+
}
264+
265+
x y {
266+
color: red;
267+
}
244268
```
245269

246270
### css_global_block_invalid_modifier

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,43 @@ Certain lifecycle methods can only be used during component initialisation. To f
244244
<button onclick={handleClick}>click me</button>
245245
```
246246

247+
### snippet_without_render_tag
248+
249+
```
250+
Attempted to render a snippet without a `{@render}` block. This would cause the snippet code to be stringified instead of its content being rendered to the DOM. To fix this, change `{snippet}` to `{@render snippet()}`.
251+
```
252+
253+
A component throwing this error will look something like this (`children` is not being rendered):
254+
255+
```svelte
256+
<script>
257+
let { children } = $props();
258+
</script>
259+
260+
{children}
261+
```
262+
263+
...or like this (a parent component is passing a snippet where a non-snippet value is expected):
264+
265+
```svelte
266+
<!--- file: Parent.svelte --->
267+
<ChildComponent>
268+
{#snippet label()}
269+
<span>Hi!</span>
270+
{/snippet}
271+
</ChildComponent>
272+
```
273+
274+
```svelte
275+
<!--- file: Child.svelte --->
276+
<script>
277+
let { label } = $props();
278+
</script>
279+
280+
<!-- This component doesn't expect a snippet, but the parent provided one -->
281+
<p>{label}</p>
282+
```
283+
247284
### store_invalid_shape
248285

249286
```

0 commit comments

Comments
 (0)