forked from sveltejs/svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle destructuring to a store value (sveltejs#5452)
- Loading branch information
1 parent
10e590b
commit 24266e2
Showing
6 changed files
with
95 additions
and
38 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
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
9 changes: 9 additions & 0 deletions
9
test/runtime/samples/reactive-assignment-in-complex-declaration-with-store-2/_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 @@ | ||
// destructure to store value | ||
export default { | ||
skip_if_ssr: true, // pending https://github.com/sveltejs/svelte/issues/3582 | ||
html: `<h1>2 2 xxx 5 6 9 10 2</h1>`, | ||
async test({ assert, target, component }) { | ||
await component.update(); | ||
assert.htmlEqual(target.innerHTML, `<h1>11 11 yyy 12 13 14 15 11</h1>`); | ||
} | ||
}; |
29 changes: 29 additions & 0 deletions
29
test/runtime/samples/reactive-assignment-in-complex-declaration-with-store-2/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,29 @@ | ||
<script> | ||
import { writable } from 'svelte/store'; | ||
let eid = writable(1); | ||
let foo; | ||
const u = writable(2); | ||
const v = writable(3); | ||
const w = writable(4); | ||
const x = writable(5); | ||
const y = writable(6); | ||
[$u, $v, $w] = [ | ||
{id: eid = writable(foo = 2), name: 'xxx'}, | ||
5, | ||
6 | ||
]; | ||
({ a: $x, b: $y } = { a: 9, b: 10 }); | ||
$: z = $u.id; | ||
export function update() { | ||
[$u, $v, $w] = [ | ||
{id: eid = writable(foo = 11), name: 'yyy'}, | ||
12, | ||
13 | ||
]; | ||
({ a: $x, b: $y } = { a: 14, b: 15 }); | ||
} | ||
</script> | ||
|
||
<h1>{foo} {$eid} {$u.name} {$v} {$w} {$x} {$y} {$z}</h1> |
8 changes: 7 additions & 1 deletion
8
test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/_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 |
---|---|---|
@@ -1,3 +1,9 @@ | ||
// destructure to store | ||
export default { | ||
html: `<h1>2 2 xxx 5 6</h1>` | ||
html: `<h1>2 2 xxx 5 6 9 10 2</h1>`, | ||
skip_if_ssr: true, | ||
async test({ assert, target, component }) { | ||
await component.update(); | ||
assert.htmlEqual(target.innerHTML, `<h1>11 11 yyy 12 13 14 15 11</h1>`); | ||
} | ||
}; |
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