Skip to content

Commit 3ee44ba

Browse files
authored
Merge branch 'sveltejs:main' into docs-untrack
2 parents c9a9486 + 6b6445a commit 3ee44ba

File tree

104 files changed

+871
-232
lines changed

Some content is hidden

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

104 files changed

+871
-232
lines changed

.changeset/brave-fans-sneeze.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/early-hounds-float.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: ensure onMount correctly fires when new expressions are used

.changeset/sweet-candles-poke.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/tasty-frogs-boil.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/wild-parents-begin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: ensure custom element attribute/prop changes are in their own context

.github/workflows/sync-request.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Sync request
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
dispatch:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Repository Dispatch
13+
uses: peter-evans/repository-dispatch@v3
14+
with:
15+
token: ${{ secrets.SYNC_REQUEST_TOKEN }}
16+
repository: sveltejs/svelte.dev
17+
event-type: sync-request
18+
client-payload: |-
19+
{
20+
"package": "svelte"
21+
}

documentation/docs/01-introduction/02-getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ npm run dev
1313

1414
Don't worry if you don't know Svelte yet! You can ignore all the nice features SvelteKit brings on top for now and dive into it later.
1515

16-
### Alternatives to SvelteKit
16+
## Alternatives to SvelteKit
1717

1818
You can also use Svelte directly with Vite by running `npm create vite@latest` and selecting the `svelte` option. With this, `npm run build` will generate HTML, JS and CSS files inside the `dist` directory using [vite-plugin-svelte](https://github.com/sveltejs/vite-plugin-svelte). In most cases, you will probably need to [choose a routing library](faq#Is-there-a-router) as well.
1919

2020
There are also plugins for [Rollup](https://github.com/sveltejs/rollup-plugin-svelte), [Webpack](https://github.com/sveltejs/svelte-loader) [and a few others](https://sveltesociety.dev/packages?category=build-plugins), but we recommend Vite.
2121

2222
## Editor tooling
2323

24-
The Svelte team maintains a [VS Code extension](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) and there are integrations with various other [editors](https://sveltesociety.dev/resources#editor-support) and tools as well.
24+
The Svelte team maintains a [VS Code extension](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode), and there are integrations with various other [editors](https://sveltesociety.dev/resources#editor-support) and tools as well.
2525

2626
You can also check your code from the command line using [sv check](https://github.com/sveltejs/cli).
2727

documentation/docs/01-introduction/03-svelte-files.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ A `<script>` tag with a `module` attribute runs once when the module first evalu
5050

5151
You can `export` bindings from this block, and they will become exports of the compiled module. You cannot `export default`, since the default export is the component itself.
5252

53-
> [!NOTE] If you are using TypeScript and import such exports from a `module` block into a `.ts` file, make sure to have your editor setup so that TypeScript knows about them. This is the case for our VS Code extension and the IntelliJ plugin, in other cases you might need to setup our [TypeScript editor plugin](https://www.npmjs.com/package/typescript-svelte-plugin).
53+
> [!NOTE] If you are using TypeScript and import such exports from a `module` block into a `.ts` file, make sure to have your editor setup so that TypeScript knows about them. This is the case for our VS Code extension and the IntelliJ plugin, but in other cases you might need to setup our [TypeScript editor plugin](https://www.npmjs.com/package/typescript-svelte-plugin).
5454
5555
> [!LEGACY]
5656
> In Svelte 4, this script tag was created using `<script context="module">`

documentation/docs/02-runes/03-$derived.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The expression inside `$derived(...)` should be free of side-effects. Svelte wil
2121

2222
As with `$state`, you can mark class fields as `$derived`.
2323

24-
> [!NOTE] Code in Svelte components is only executed once at creation, without the `$derived` rune `double` would maintain it's original value.
24+
> [!NOTE] Code in Svelte components is only executed once at creation. Without the `$derived` rune, `doubled` would maintain its original value even when `count` changes.
2525
2626
## `$derived.by`
2727

documentation/docs/02-runes/04-$effect.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,7 @@ export default function readable<T>(
243243

244244
## `$effect.root`
245245

246-
The `$effect.root` rune is an advanced feature that creates a non-tracked scope that doesn't auto-cleanup. This is useful for
247-
nested effects that you want to manually control. This rune also allows for creation of effects outside of the component initialisation phase.
246+
The `$effect.root` rune is an advanced feature that creates a non-tracked scope that doesn't auto-cleanup. This is useful for nested effects that you want to manually control. This rune also allows for the creation of effects outside of the component initialisation phase.
248247

249248
```svelte
250249
<script>

documentation/docs/02-runes/07-$inspect.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: $inspect
33
---
44

5+
> [!NOTE] `$inspect` only works during development. In a production build it becomes a noop.
6+
57
The `$inspect` rune is roughly equivalent to `console.log`, with the exception that it will re-run whenever its argument changes. `$inspect` tracks reactive state deeply, meaning that updating something inside an object or array using fine-grained reactivity will cause it to re-fire ([demo](/playground/untitled#H4sIAAAAAAAACkWQ0YqDQAxFfyUMhSotdZ-tCvu431AXtGOqQ2NmmMm0LOK_r7Utfby5JzeXTOpiCIPKT5PidkSVq2_n1F7Jn3uIcEMSXHSw0evHpAjaGydVzbUQCmgbWaCETZBWMPlKj29nxBDaHj_edkAiu12JhdkYDg61JGvE_s2nR8gyuBuiJZuDJTyQ7eE-IEOzog1YD80Lb0APLfdYc5F9qnFxjiKWwbImo6_llKRQVs-2u91c_bD2OCJLkT3JZasw7KLA2XCX31qKWE6vIzNk1fKE0XbmYrBTufiI8-_8D2cUWBA_AQAA)):
68

79
```svelte
@@ -40,5 +42,3 @@ A convenient way to find the origin of some change is to pass `console.trace` to
4042
// @errors: 2304
4143
$inspect(stuff).with(console.trace);
4244
```
43-
44-
> [!NOTE] `$inspect` only works during development. In a production build it becomes a noop.

documentation/docs/03-template-syntax/01-basic-markup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Timing-wise, event attributes always fire after events from bindings (e.g. `onin
109109

110110
When using `ontouchstart` and `ontouchmove` event attributes, the handlers are [passive](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#using_passive_listeners) for better performance. This greatly improves responsiveness by allowing the browser to scroll the document immediately, rather than waiting to see if the event handler calls `event.preventDefault()`.
111111

112-
In the very rare cases that you need to prevent these event defaults, you should use [`on`](https://svelte-5-preview.vercel.app/docs/imports#svelte-events) instead (for example inside an action).
112+
In the very rare cases that you need to prevent these event defaults, you should use [`on`](svelte-events#on) instead (for example inside an action).
113113

114114
### Event delegation
115115

documentation/docs/03-template-syntax/05-await.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Await blocks allow you to branch on the three possible states of a [`Promise`](h
3939

4040
> [!NOTE] During server-side rendering, only the pending branch will be rendered.
4141
>
42-
> If the provided expression is not a `Promise` only the `:then` branch will be rendered, including during server-side rendering.
42+
> If the provided expression is not a `Promise`, only the `:then` branch will be rendered, including during server-side rendering.
4343
4444
The `catch` block can be omitted if you don't need to render anything when the promise rejects (or no error is possible).
4545

documentation/docs/03-template-syntax/06-snippet.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Snippets, and [render tags](@render), are a way to create reusable chunks of mar
5353
{/each}
5454
```
5555

56-
Like function declarations, snippets can have an arbitrary number of parameters, which can have default values, and you can destructure each parameter. You cannot use rest parameters however.
56+
Like function declarations, snippets can have an arbitrary number of parameters, which can have default values, and you can destructure each parameter. You cannot use rest parameters, however.
5757

5858
## Snippet scope
5959

documentation/docs/03-template-syntax/14-in-and-out.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,18 @@ title: in: and out:
55
The `in:` and `out:` directives are identical to [`transition:`](transition), except that the resulting transitions are not bidirectional — an `in` transition will continue to 'play' alongside the `out` transition, rather than reversing, if the block is outroed while the transition is in progress. If an out transition is aborted, transitions will restart from scratch.
66

77
```svelte
8+
<script>
9+
import { fade, fly } from 'svelte/transition';
10+
11+
let visible = $state(false);
12+
</script>
13+
14+
<label>
15+
<input type="checkbox" bind:checked={visible}>
16+
visible
17+
</label>
18+
819
{#if visible}
9-
<div in:fly out:fade>flies in, fades out</div>
20+
<div in:fly={{ y: 200 }} out:fade>flies in, fades out</div>
1021
{/if}
1122
```

documentation/docs/03-template-syntax/15-animate.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
title: animate:
33
---
44

5-
6-
7-
85
An animation is triggered when the contents of a [keyed each block](each#Keyed-each-blocks) are re-ordered. Animations do not run when an element is added or removed, only when the index of an existing data item within the each block changes. Animate directives must be on an element that is an _immediate_ child of a keyed each block.
96

107
Animations can be used with Svelte's [built-in animation functions](svelte-animate) or [custom animation functions](#Custom-animation-functions).
118

129
```svelte
13-
<!-- When `list` is reordered the animation will run-->
10+
<!-- When `list` is reordered the animation will run -->
1411
{#each list as item, index (item)}
1512
<li animate:flip>{item}</li>
1613
{/each}
@@ -115,4 +112,3 @@ A custom animation function can also return a `tick` function, which is called _
115112
<div animate:whizz>{item}</div>
116113
{/each}
117114
```
118-

documentation/docs/04-styling/04-nested-style-elements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Nested <style> elements
33
---
44

5-
There should only be 1 top-level `<style>` tag per component.
5+
There can only be one top-level `<style>` tag per component.
66

77
However, it is possible to have a `<style>` tag nested inside other elements or logic blocks.
88

documentation/docs/05-special-elements/06-svelte-options.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ title: <svelte:options>
88

99
The `<svelte:options>` element provides a place to specify per-component compiler options, which are detailed in the [compiler section](svelte-compiler#compile). The possible options are:
1010

11-
- `immutable={true}` — you never use mutable data, so the compiler can do simple referential equality checks to determine if values have changed
12-
- `immutable={false}` — the default. Svelte will be more conservative about whether or not mutable objects have changed
13-
- `accessors={true}` — adds getters and setters for the component's props
14-
- `accessors={false}` — the default
1511
- `runes={true}` — forces a component into _runes mode_ (see the [Legacy APIs](legacy-overview) section)
1612
- `runes={false}` — forces a component into _legacy mode_
17-
- `namespace="..."` — the namespace where this component will be used, most commonly "svg"; use the "foreign" namespace to opt out of case-insensitive attribute names and HTML-specific warnings
13+
- `namespace="..."` — the namespace where this component will be used, can be "html" (the default), "svg" or "mathml"
1814
- `customElement={...}` — the [options](custom-elements#Component-options) to use when compiling this component as a custom element. If a string is passed, it is used as the `tag` option
15+
- `css="injected"` — the component will inject its styles inline: During server side rendering, it's injected as a `<style>` tag in the `head`, during client side rendering, it's loaded via JavaScript
16+
17+
> [!LEGACY] Deprecated options
18+
> Svelte 4 also included the following options. They are deprecated in Svelte 5 and non-functional in runes mode.
19+
>
20+
> - `immutable={true}` — you never use mutable data, so the compiler can do simple referential equality checks to determine if values have changed
21+
> - `immutable={false}` — the default. Svelte will be more conservative about whether or not mutable objects have changed
22+
> - `accessors={true}` — adds getters and setters for the component's props
23+
> - `accessors={false}` — the default
1924
2025
```svelte
2126
<svelte:options customElement="my-custom-element" />

documentation/docs/06-runtime/01-stores.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Local variables (that do not represent store values) must _not_ have a `$` prefi
3636
Prior to Svelte 5, stores were the go-to solution for creating cross-component reactive states or extracting logic. With runes, these use cases have greatly diminished.
3737

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)
39-
- when creating shared state, you can create a `$state` object containing the values you need and manipulating said state
39+
- when creating shared state, you can create a `$state` object containing the values you need and then manipulate said state
4040

4141
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.
4242

documentation/docs/06-runtime/03-lifecycle-hooks.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: Lifecycle hooks
77
- beforeUpdate/afterUpdate with deprecation notice?
88
- or skip this entirely and only have it in the reference docs? -->
99

10-
In Svelte 5, the component lifecycle consists of only two parts: Its creation and its destruction. Everything in-between - when certain state is updated - is not related to the component as a whole, only the parts that need to react to the state change are notified. This is because under the hood the smallest unit of change is actually not a component, it's the (render) effects that the component sets up upon component initialization. Consequently, there's no such thing as a "before update"/"after update" hook.
10+
In Svelte 5, the component lifecycle consists of only two parts: Its creation and its destruction. Everything in-between when certain state is updated is not related to the component as a whole; only the parts that need to react to the state change are notified. This is because under the hood the smallest unit of change is actually not a component, it's the (render) effects that the component sets up upon component initialization. Consequently, there's no such thing as a "before update"/"after update" hook.
1111

1212
## `onMount`
1313

@@ -67,12 +67,13 @@ While there's no "after update" hook, you can use `tick` to ensure that the UI i
6767

6868
```svelte
6969
<script>
70-
import { beforeUpdate, tick } from 'svelte';
70+
import { tick } from 'svelte';
7171
72-
beforeUpdate(async () => {
72+
$effect.pre(() => {
7373
console.log('the component is about to update');
74-
await tick();
75-
console.log('the component just updated');
74+
tick().then(
75+
console.log('the component just updated');
76+
);
7677
});
7778
</script>
7879
```

documentation/docs/98-reference/.generated/client-errors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ A component is attempting to bind to a non-bindable property `%key%` belonging t
1919
### component_api_changed
2020

2121
```
22-
%parent% called `%method%` on an instance of %component%, which is no longer valid in Svelte 5. See https://svelte-5-preview.vercel.app/docs/breaking-changes#components-are-no-longer-classes for more information
22+
%parent% called `%method%` on an instance of %component%, which is no longer valid in Svelte 5. See https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes for more information
2323
```
2424

2525
### component_api_invalid_new
2626

2727
```
28-
Attempted to instantiate %component% with `new %name%`, which is no longer valid in Svelte 5. If this component is not under your control, set the `compatibility.componentApi` compiler option to `4` to keep it working. See https://svelte-5-preview.vercel.app/docs/breaking-changes#components-are-no-longer-classes for more information
28+
Attempted to instantiate %component% with `new %name%`, which is no longer valid in Svelte 5. If this component is not under your control, set the `compatibility.componentApi` compiler option to `4` to keep it working. See https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes for more information
2929
```
3030

3131
### derived_references_self

documentation/docs/98-reference/.generated/client-warnings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Your `console.%method%` contained `$state` proxies. Consider using `$inspect(...
1616

1717
When logging a [proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy), browser devtools will log the proxy itself rather than the value it represents. In the case of Svelte, the 'target' of a `$state` proxy might not resemble its current value, which can be confusing.
1818

19-
The easiest way to log a value as it changes over time is to use the [`$inspect`](https://svelte-5-preview.vercel.app/docs/runes#$inspect) rune. Alternatively, to log things on a one-off basis (for example, inside an event handler) you can use [`$state.snapshot`](https://svelte-5-preview.vercel.app/docs/runes#$state-snapshot) to take a snapshot of the current value.
19+
The easiest way to log a value as it changes over time is to use the [`$inspect`](https://svelte.dev/docs/svelte/$inspect) rune. Alternatively, to log things on a one-off basis (for example, inside an event handler) you can use [`$state.snapshot`](https://svelte.dev/docs/svelte/$state#$state.snapshot) to take a snapshot of the current value.
2020

2121
### event_handler_invalid
2222

documentation/docs/98-reference/.generated/compile-errors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Can only bind to state or props
119119
### block_invalid_continuation_placement
120120

121121
```
122-
{:...} block is invalid at this position (did you forget to close the preceeding element or block?)
122+
{:...} block is invalid at this position (did you forget to close the preceding element or block?)
123123
```
124124

125125
### block_invalid_elseif

documentation/docs/99-legacy/00-legacy-overview.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ The following pages document these features for
1010
- people using Svelte 5, but with components that haven't yet been migrated
1111

1212
Since Svelte 3/4 syntax still works in Svelte 5, we will distinguish between _legacy mode_ and _runes mode_. Once a component is in runes mode (which you can opt into by using runes, or by explicitly setting the `runes: true` compiler option), legacy mode features are no longer available.
13+
14+
If you're exclusively interested in the Svelte 3/4 syntax, you can browse its documentation at [v4.svelte.dev](https://v4.svelte.dev).

package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,5 @@
4545
"typescript-eslint": "^8.2.0",
4646
"v8-natives": "^1.2.5",
4747
"vitest": "^2.0.5"
48-
},
49-
"pnpm": {
50-
"overrides": {
51-
"xml2js": "^0.6.0"
52-
}
5348
}
5449
}

packages/svelte/CHANGELOG.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,53 @@
11
# svelte
22

3+
## 5.1.6
4+
5+
### Patch Changes
6+
7+
- fix: ensure child effects are destroyed before their deriveds ([#14043](https://github.com/sveltejs/svelte/pull/14043))
8+
9+
## 5.1.5
10+
11+
### Patch Changes
12+
13+
- fix: replace typo in compiler error messages ([#14044](https://github.com/sveltejs/svelte/pull/14044))
14+
15+
- fix: preserve the separator between selectors when an unused selector is in between ([#13954](https://github.com/sveltejs/svelte/pull/13954))
16+
17+
- fix: more robust re-subscribe detection for `fromStore` ([#13995](https://github.com/sveltejs/svelte/pull/13995))
18+
19+
- fix: allow to pass in TS preference to migration ([#13929](https://github.com/sveltejs/svelte/pull/13929))
20+
21+
- fix: extend derived/state validation error to indirect exports ([#14039](https://github.com/sveltejs/svelte/pull/14039))
22+
23+
- fix: minify inject CSS in prod mode ([#14006](https://github.com/sveltejs/svelte/pull/14006))
24+
25+
- fix: ensure toStore subscription correctly syncs latest value ([#14015](https://github.com/sveltejs/svelte/pull/14015))
26+
27+
- fix: don't access `requestAnimationFrame` until needed to reduce need for mocks during testing ([#14040](https://github.com/sveltejs/svelte/pull/14040))
28+
29+
- fix: ensure element effects are executed in the correct order ([#14038](https://github.com/sveltejs/svelte/pull/14038))
30+
31+
- fix: make compiler error extend from `Error` ([#14036](https://github.com/sveltejs/svelte/pull/14036))
32+
33+
## 5.1.4
34+
35+
### Patch Changes
36+
37+
- fix: add empty stack to `CompileDiagnostic` to show error on build ([#13942](https://github.com/sveltejs/svelte/pull/13942))
38+
39+
- fix: ensure effect_tracking correctly handles tracking reactions ([#14005](https://github.com/sveltejs/svelte/pull/14005))
40+
41+
- fix: update broken links ([#13944](https://github.com/sveltejs/svelte/pull/13944))
42+
43+
- fix: more exhaustive check during `SvelteMap.set` in deriveds ([#13951](https://github.com/sveltejs/svelte/pull/13951))
44+
45+
- fix: trim whitespace while migrating blocks ([#13941](https://github.com/sveltejs/svelte/pull/13941))
46+
47+
- fix: update links that previously pointed to preview site ([#14001](https://github.com/sveltejs/svelte/pull/14001))
48+
49+
- fix: properly migrate imports types prefixed with $ ([#14007](https://github.com/sveltejs/svelte/pull/14007))
50+
351
## 5.1.3
452

553
### Patch Changes

0 commit comments

Comments
 (0)