-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] support destructured declaration of props (#6578)
- Loading branch information
Showing
11 changed files
with
271 additions
and
56 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
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,24 @@ | ||
<script> | ||
import { writable } from 'svelte/store'; | ||
const THING = { a: 1, b: { c: 2, d: [3, 4, writable(5)] }, e: [6], h: 8 }; | ||
const default_g = 9; | ||
export let { a, b: { c, d: [d_one,,d_three], f }, e: [e_one], g = default_g } = THING; | ||
export const { a: A, b: { c: C } } = THING; | ||
</script> | ||
|
||
<div> | ||
a: {a}, | ||
b: {typeof b}, | ||
c: {c}, | ||
d_one: {d_one}, | ||
d_three: {$d_three}, | ||
f: {f}, | ||
g: {g}, | ||
e: {typeof e}, | ||
e_one: {e_one}, | ||
A: {A}, | ||
C: {C} | ||
</div> | ||
<div>{JSON.stringify(THING)}</div> |
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 @@ | ||
export default { | ||
html: ` | ||
<div>a: 1, b: undefined, c: 2, d_one: 3, d_three: 5, f: undefined, g: 9, e: undefined, e_one: 6, A: 1, C: 2</div> | ||
<div>{"a":1,"b":{"c":2,"d":[3,4,{}]},"e":[6],"h":8}</div> | ||
<br> | ||
<div>a: a, b: undefined, c: 2, d_one: d_one, d_three: 5, f: f, g: g, e: undefined, e_one: 6, A: 1, C: 2</div> | ||
<div>{"a":1,"b":{"c":2,"d":[3,4,{}]},"e":[6],"h":8}</div> | ||
` | ||
}; |
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,7 @@ | ||
<script> | ||
import A from './A.svelte'; | ||
</script> | ||
|
||
<A /> | ||
<br /> | ||
<A a="a" d_one="d_one" list_one="list_one" f="f" list_two_b="list_two_b" g="g" A="A" C="C" /> |
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,21 @@ | ||
<script> | ||
import { writable } from 'svelte/store'; | ||
let default_b = 5; | ||
const LIST = [1, { a: 2 }, [3, writable(4)]]; | ||
export const [x, { a: list_two_a, b: list_two_b = default_b }, [, y]] = LIST; | ||
export let [m, { a: n, b: o = default_b }, [p, q]] = LIST; | ||
</script> | ||
|
||
<div> | ||
x: {x}, | ||
list_two_a: {list_two_a}, | ||
list_two_b: {list_two_b}, | ||
y: {$y}, | ||
m: {m}, | ||
n: {n}, | ||
o: {o}, | ||
p: {p}, | ||
q: {$q} | ||
</div> | ||
<div>{JSON.stringify(LIST)}</div> |
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,19 @@ | ||
export default { | ||
html: ` | ||
<div>x: 1, list_two_a: 2, list_two_b: 5, y: 4, m: 1, n: 2, o: 5, p: 3, q: 4</div> | ||
<div>[1,{"a":2},[3,{}]]</div> | ||
<br><div>x: 1, list_two_a: 2, list_two_b: 5, y: 4, m: m, n: n, o: o, p: p, q: q</div> | ||
<div>[1,{"a":2},[3,{}]]</div> | ||
`, | ||
|
||
async test({ component, assert, target }) { | ||
await component.update(); | ||
|
||
assert.htmlEqual(target.innerHTML, ` | ||
<div>x: 1, list_two_a: 2, list_two_b: 5, y: 4, m: 1, n: 2, o: 5, p: 3, q: 4</div> | ||
<div>[1,{"a":2},[3,{}]]</div> | ||
<br><div>x: 1, list_two_a: 2, list_two_b: 5, y: 4, m: MM, n: NN, o: OO, p: PP, q: QQ</div> | ||
<div>[1,{"a":2},[3,{}]]</div> | ||
`); | ||
} | ||
}; |
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,30 @@ | ||
<script> | ||
import A from './A.svelte'; | ||
import { writable } from 'svelte/store'; | ||
let x = 'x', | ||
list_two_a = 'list_two_a', | ||
list_two_b = 'list_two_b', | ||
y = writable('y'), | ||
m = 'm', | ||
n = 'n', | ||
o = 'o', | ||
p = 'p', | ||
q = writable('q'); | ||
export function update() { | ||
x = 'XX'; | ||
list_two_a = 'LIST_TWO_A'; | ||
list_two_b = 'LIST_TWO_B'; | ||
y = writable('YY'); | ||
m = 'MM'; | ||
n = 'NN'; | ||
o = 'OO'; | ||
p = 'PP'; | ||
q = writable('QQ'); | ||
} | ||
</script> | ||
|
||
<A /> | ||
<br /> | ||
<A {x} {list_two_a} {list_two_b} {y} {m} {n} {o} {p} {q} /> |
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,10 @@ | ||
<script> | ||
import { writable } from 'svelte/store'; | ||
const { i, j, k } = { i: 9, j: 10, k: writable(11) }, l = 12, m = 13, n = writable(14); | ||
let { a, b, c } = { a: 9, b: 10, c: writable(11) }, d = 12, e = 13, f = writable(14); | ||
export { i, k, l, n, a, c, d, f }; | ||
</script> | ||
|
||
<div>i: {i}, j: {j}, k: {$k}, l: {l}, m: {m}, n: {$n}, a: {a}, b: {b}, c: {$c}, d: {d}, e: {e}, f: {$f}</div> |
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,15 @@ | ||
export default { | ||
html: ` | ||
<div>i: 9, j: 10, k: 11, l: 12, m: 13, n: 14, a: 9, b: 10, c: 11, d: 12, e: 13, f: 14</div> | ||
<br> | ||
<div>i: 9, j: 10, k: 11, l: 12, m: 13, n: 14, a: a, b: 10, c: c, d: d, e: 13, f: f</div> | ||
`, | ||
async test({ component, target, assert }) { | ||
await component.update(); | ||
assert.htmlEqual(target.innerHTML, ` | ||
<div>i: 9, j: 10, k: 11, l: 12, m: 13, n: 14, a: 9, b: 10, c: 11, d: 12, e: 13, f: 14</div> | ||
<br> | ||
<div>i: 9, j: 10, k: 11, l: 12, m: 13, n: 14, a: aa, b: 10, c: cc, d: dd, e: 13, f: ff</div> | ||
`); | ||
} | ||
}; |
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 A from './A.svelte'; | ||
import { writable } from 'svelte/store'; | ||
let i = 'i', | ||
k = writable('k'), | ||
l = 'l', | ||
n = writable('n'), | ||
a = 'a', | ||
c = writable('c'), | ||
d = 'd', | ||
f = writable('f'); | ||
export function update() { | ||
i = 'ii'; | ||
k = writable('kk'); | ||
l = 'll'; | ||
n = writable('nn'); | ||
a = 'aa'; | ||
c = writable('cc'); | ||
d = 'dd'; | ||
f = writable('ff'); | ||
} | ||
</script> | ||
|
||
<A /> | ||
<br /> | ||
<A {i} {k} {l} {n} {a} {c} {d} {f} /> |