Skip to content

Commit 13ce43a

Browse files
docs: document more breaking changes (#11636)
* docs: document more breaking changes Related to #11400 closes #11590 * Update sites/svelte-5-preview/src/routes/docs/content/03-appendix/02-breaking-changes.md Co-authored-by: Rich Harris <[email protected]> * Update sites/svelte-5-preview/src/routes/docs/content/03-appendix/02-breaking-changes.md Co-authored-by: Rich Harris <[email protected]> --------- Co-authored-by: Rich Harris <[email protected]>
1 parent 4f8bba2 commit 13ce43a

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

sites/svelte-5-preview/src/routes/docs/content/03-appendix/02-breaking-changes.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,25 @@ In Svelte 4 syntax, every property (declared via `export let`) is bindable, mean
133133

134134
Setting the `accessors` option to `true` makes properties of a component directly accessible on the component instance. In runes mode, properties are never accessible on the component instance. You can use component exports instead if you need to expose them.
135135

136+
### `immutable` option is ignored
137+
138+
Setting the `immutable` option has no effect in runes mode. This concept is replaced by how `$state` and its variations work.
139+
140+
### Classes are no longer "auto-reactive"
141+
142+
In Svelte 4, doing the following triggered reactivity:
143+
144+
```svelte
145+
<script>
146+
let foo = new Foo();
147+
</script>
148+
149+
<button on:click={() => (foo.value = 1)}>{foo.value}</button
150+
>
151+
```
152+
153+
This is because the Svelte compiler treated the assignment to `foo.value` as an instruction to update anything that referenced `foo`. In Svelte 5, reactivity is determined at runtime rather than compile time, so you should define `value` as a reactive `$state` field on the `Foo` class. Wrapping `new Foo()` with `$state(...)` will have no effect — only vanilla objects and arrays are made deeply reactive.
154+
136155
## Other breaking changes
137156

138157
### Stricter `@const` assignment validation
@@ -158,9 +177,9 @@ In the event that you need to support ancient browsers that don't implement `:wh
158177
css = css.replace(/:where\((.+?)\)/, '$1');
159178
```
160179

161-
### Renames of various error/warning codes
180+
### Error/warning codes have been renamed
162181

163-
Various error and warning codes have been renamed slightly.
182+
Error and warning codes have been renamed. Previously they used dashes to separate the words, they now use underscores (e.g. foo-bar becomes foo_bar). Additionally, a handful of codes have been reworded slightly.
164183

165184
### Reduced number of namespaces
166185

@@ -203,3 +222,11 @@ Previously, bindings did not take into account `reset` event of forms, and there
203222
### `walk` not longer exported
204223

205224
`svelte/compiler` reexported `walk` from `estree-walker` for convenience. This is no longer true in Svelte 5, import it directly from that package instead in case you need it.
225+
226+
### Content inside `svelte:options` is forbidden
227+
228+
In Svelte 4 you could have content inside a `<svelte:options />` tag. It was ignored, but you could write something in there. In Svelte 5, content inside that tag is a compiler error.
229+
230+
### `<slot>` elements in declarative shadow roots are preserved
231+
232+
Svelte 4 replaced the `<slot />` tag in all places with its own version of slots. Svelte 5 preserves them in the case they are a child of a `<template shadowrootmode="...">` element.

0 commit comments

Comments
 (0)