-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: replicate Svelte 4 props update detection in legacy mode (#11577)
* fix: replicate Svelte 4 props update detection in legacy mode fixes #11448 by wrapping props in deriveds * fix test * Update packages/svelte/src/compiler/phases/3-transform/client/utils.js Co-authored-by: Rich Harris <rich.harris@vercel.com> * dedicated flag * prettier --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>
- Loading branch information
1 parent
a0bdac8
commit d408d20
Showing
10 changed files
with
79 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"svelte": patch | ||
--- | ||
|
||
fix: replicate Svelte 4 props update detection in legacy mode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/svelte/tests/runtime-legacy/samples/prop-no-change/Nested.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<script> | ||
export let primitive; | ||
export let object; | ||
$: primitive && console.log('primitive'); | ||
$: object && console.log('object'); | ||
</script> |
9 changes: 9 additions & 0 deletions
9
packages/svelte/tests/runtime-legacy/samples/prop-no-change/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
async test({ assert, logs, target }) { | ||
assert.deepEqual(logs, ['primitive', 'object']); | ||
await target.querySelector('button')?.click(); | ||
assert.deepEqual(logs, ['primitive', 'object', 'object']); | ||
} | ||
}); |
8 changes: 8 additions & 0 deletions
8
packages/svelte/tests/runtime-legacy/samples/prop-no-change/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<script> | ||
import Nested from './Nested.svelte'; | ||
let value = { count: 1 }; | ||
</script> | ||
|
||
<button on:click={() => value = { count: 1 }}>reassign</button> | ||
<Nested primitive={value.count} object={value} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
client: ['foo.bar.baz'], | ||
server: ['foo.bar.baz'] | ||
client: ['bar.baz'], | ||
server: ['bar.baz'] | ||
}); |