ripple 0.3.71 → 0.3.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +75 -0
- package/package.json +3 -3
- package/src/jsx-runtime.d.ts +2 -8
- package/src/runtime/index-client.js +3 -13
- package/src/runtime/internal/client/blocks.js +3 -25
- package/src/runtime/internal/client/for.js +80 -5
- package/src/runtime/internal/client/index.js +0 -2
- package/src/runtime/internal/client/types.d.ts +0 -10
- package/tests/client/__snapshots__/computed-properties.test.tsrx.snap +8 -0
- package/tests/client/__snapshots__/for.test.tsrx.snap +22 -0
- package/tests/client/__snapshots__/html.test.tsrx.snap +4 -0
- package/tests/client/array/array.copy-within.test.tsrx +19 -19
- package/tests/client/array/array.derived.test.tsrx +97 -109
- package/tests/client/array/array.iteration.test.tsrx +28 -28
- package/tests/client/array/array.mutations.test.tsrx +68 -68
- package/tests/client/array/array.static.test.tsrx +82 -92
- package/tests/client/array/array.to-methods.test.tsrx +15 -15
- package/tests/client/async-suspend.test.tsrx +180 -179
- package/tests/client/basic/__snapshots__/basic.attributes.test.tsrx.snap +2 -0
- package/tests/client/basic/__snapshots__/basic.rendering.test.tsrx.snap +4 -0
- package/tests/client/basic/basic.attributes.test.tsrx +273 -317
- package/tests/client/basic/basic.collections.test.tsrx +59 -71
- package/tests/client/basic/basic.components.test.tsrx +196 -222
- package/tests/client/basic/basic.errors.test.tsrx +72 -78
- package/tests/client/basic/basic.events.test.tsrx +80 -85
- package/tests/client/basic/basic.get-set.test.tsrx +54 -64
- package/tests/client/basic/basic.hmr.test.tsrx +15 -19
- package/tests/client/basic/basic.reactivity.test.tsrx +121 -135
- package/tests/client/basic/basic.rendering.test.tsrx +273 -178
- package/tests/client/basic/basic.utilities.test.tsrx +8 -10
- package/tests/client/boundaries.test.tsrx +18 -18
- package/tests/client/compiler/compiler.assignments.test.tsrx +77 -76
- package/tests/client/compiler/compiler.attributes.test.tsrx +18 -14
- package/tests/client/compiler/compiler.basic.test.tsrx +364 -296
- package/tests/client/compiler/compiler.regex.test.tsrx +40 -44
- package/tests/client/compiler/compiler.tracked-access.test.tsrx +57 -38
- package/tests/client/compiler/compiler.try-in-function.test.tsrx +16 -16
- package/tests/client/compiler/compiler.typescript.test.tsrx +4 -3
- package/tests/client/composite/composite.dynamic-components.test.tsrx +41 -44
- package/tests/client/composite/composite.generics.test.tsrx +165 -167
- package/tests/client/composite/composite.props.test.tsrx +66 -74
- package/tests/client/composite/composite.reactivity.test.tsrx +132 -166
- package/tests/client/composite/composite.render.test.tsrx +92 -101
- package/tests/client/computed-properties.test.tsrx +14 -18
- package/tests/client/context.test.tsrx +14 -18
- package/tests/client/css/global-additional-cases.test.tsrx +491 -437
- package/tests/client/css/global-advanced-selectors.test.tsrx +169 -153
- package/tests/client/css/global-at-rules.test.tsrx +71 -66
- package/tests/client/css/global-basic.test.tsrx +105 -98
- package/tests/client/css/global-classes-ids.test.tsrx +128 -114
- package/tests/client/css/global-combinators.test.tsrx +83 -78
- package/tests/client/css/global-complex-nesting.test.tsrx +134 -120
- package/tests/client/css/global-edge-cases.test.tsrx +138 -120
- package/tests/client/css/global-keyframes.test.tsrx +108 -96
- package/tests/client/css/global-nested.test.tsrx +88 -78
- package/tests/client/css/global-pseudo.test.tsrx +104 -98
- package/tests/client/css/global-scoping.test.tsrx +145 -125
- package/tests/client/css/style-identifier.test.tsrx +62 -69
- package/tests/client/date.test.tsrx +83 -83
- package/tests/client/dynamic-elements.test.tsrx +227 -283
- package/tests/client/events.test.tsrx +252 -266
- package/tests/client/for.test.tsrx +120 -127
- package/tests/client/head.test.tsrx +40 -48
- package/tests/client/html.test.tsrx +37 -49
- package/tests/client/input-value.test.tsrx +1125 -1354
- package/tests/client/lazy-array.test.tsrx +10 -16
- package/tests/client/lazy-destructuring.test.tsrx +169 -221
- package/tests/client/map.test.tsrx +39 -41
- package/tests/client/media-query.test.tsrx +15 -19
- package/tests/client/object.test.tsrx +46 -56
- package/tests/client/portal.test.tsrx +31 -37
- package/tests/client/ref.test.tsrx +173 -193
- package/tests/client/return.test.tsrx +62 -37
- package/tests/client/set.test.tsrx +33 -33
- package/tests/client/svg.test.tsrx +195 -215
- package/tests/client/switch.test.tsrx +201 -191
- package/tests/client/track-async-hydration.test.tsrx +14 -18
- package/tests/client/tracked-index-access.test.tsrx +18 -28
- package/tests/client/try.test.tsrx +494 -619
- package/tests/client/tsx.test.tsrx +290 -371
- package/tests/client/typescript-generics.test.tsrx +121 -129
- package/tests/client/url/url.derived.test.tsrx +21 -25
- package/tests/client/url/url.parsing.test.tsrx +35 -35
- package/tests/client/url/url.partial-removal.test.tsrx +32 -32
- package/tests/client/url/url.reactivity.test.tsrx +68 -72
- package/tests/client/url/url.serialization.test.tsrx +8 -8
- package/tests/client/url-search-params/url-search-params.derived.test.tsrx +21 -27
- package/tests/client/url-search-params/url-search-params.initialization.test.tsrx +16 -16
- package/tests/client/url-search-params/url-search-params.iteration.test.tsrx +37 -37
- package/tests/client/url-search-params/url-search-params.mutation.test.tsrx +56 -60
- package/tests/client/url-search-params/url-search-params.retrieval.test.tsrx +32 -34
- package/tests/client/url-search-params/url-search-params.serialization.test.tsrx +9 -9
- package/tests/client/url-search-params/url-search-params.tracked-url.test.tsrx +10 -10
- package/tests/hydration/compiled/client/basic.js +396 -325
- package/tests/hydration/compiled/client/composite.js +52 -44
- package/tests/hydration/compiled/client/for.js +734 -604
- package/tests/hydration/compiled/client/head.js +183 -103
- package/tests/hydration/compiled/client/html.js +93 -86
- package/tests/hydration/compiled/client/if-children.js +95 -71
- package/tests/hydration/compiled/client/if.js +113 -89
- package/tests/hydration/compiled/client/mixed-control-flow.js +225 -209
- package/tests/hydration/compiled/client/nested-control-flow.js +94 -98
- package/tests/hydration/compiled/client/reactivity.js +26 -24
- package/tests/hydration/compiled/client/return.js +8 -42
- package/tests/hydration/compiled/client/switch.js +208 -173
- package/tests/hydration/compiled/client/track-async-serialization.js +176 -128
- package/tests/hydration/compiled/client/try.js +29 -21
- package/tests/hydration/compiled/server/basic.js +210 -221
- package/tests/hydration/compiled/server/composite.js +13 -14
- package/tests/hydration/compiled/server/for.js +427 -444
- package/tests/hydration/compiled/server/head.js +199 -189
- package/tests/hydration/compiled/server/html.js +33 -41
- package/tests/hydration/compiled/server/if-children.js +114 -117
- package/tests/hydration/compiled/server/if.js +77 -83
- package/tests/hydration/compiled/server/mixed-control-flow.js +145 -150
- package/tests/hydration/compiled/server/nested-control-flow.js +10 -0
- package/tests/hydration/compiled/server/reactivity.js +24 -22
- package/tests/hydration/compiled/server/return.js +6 -18
- package/tests/hydration/compiled/server/switch.js +179 -176
- package/tests/hydration/compiled/server/track-async-serialization.js +88 -70
- package/tests/hydration/compiled/server/try.js +31 -35
- package/tests/hydration/components/basic.tsrx +216 -286
- package/tests/hydration/components/composite.tsrx +32 -42
- package/tests/hydration/components/events.tsrx +81 -101
- package/tests/hydration/components/for.tsrx +270 -336
- package/tests/hydration/components/head.tsrx +43 -39
- package/tests/hydration/components/hmr.tsrx +16 -22
- package/tests/hydration/components/html-in-template.tsrx +15 -21
- package/tests/hydration/components/html.tsrx +442 -526
- package/tests/hydration/components/if-children.tsrx +107 -125
- package/tests/hydration/components/if.tsrx +68 -90
- package/tests/hydration/components/mixed-control-flow.tsrx +65 -72
- package/tests/hydration/components/nested-control-flow.tsrx +202 -216
- package/tests/hydration/components/portal.tsrx +33 -41
- package/tests/hydration/components/reactivity.tsrx +26 -34
- package/tests/hydration/components/return.tsrx +4 -6
- package/tests/hydration/components/switch.tsrx +73 -78
- package/tests/hydration/components/track-async-serialization.tsrx +83 -93
- package/tests/hydration/components/try.tsrx +37 -51
- package/tests/hydration/switch.test.js +8 -8
- package/tests/server/await.test.tsrx +3 -3
- package/tests/server/basic.attributes.test.tsrx +120 -167
- package/tests/server/basic.components.test.tsrx +163 -197
- package/tests/server/basic.test.tsrx +298 -220
- package/tests/server/compiler.test.tsrx +142 -72
- package/tests/server/composite.props.test.tsrx +54 -58
- package/tests/server/composite.test.tsrx +165 -167
- package/tests/server/context.test.tsrx +13 -17
- package/tests/server/dynamic-elements.test.tsrx +103 -135
- package/tests/server/for.test.tsrx +115 -84
- package/tests/server/head.test.tsrx +31 -31
- package/tests/server/html-nesting-validation.test.tsrx +16 -8
- package/tests/server/if.test.tsrx +49 -59
- package/tests/server/lazy-destructuring.test.tsrx +288 -366
- package/tests/server/return.test.tsrx +58 -36
- package/tests/server/streaming-ssr.test.tsrx +4 -4
- package/tests/server/style-identifier.test.tsrx +58 -66
- package/tests/server/switch.test.tsrx +89 -97
- package/tests/server/track-async-serialization.test.tsrx +85 -103
- package/tests/server/try.test.tsrx +275 -360
- package/tests/utils/ref-types.test.js +72 -0
- package/tests/utils/vite-plugin-config.test.js +41 -74
- package/types/index.d.ts +1 -0
- package/src/runtime/internal/client/compat.js +0 -40
- package/tests/utils/compiler-compat-config.test.js +0 -38
|
@@ -3,13 +3,11 @@ import { track } from 'ripple';
|
|
|
3
3
|
|
|
4
4
|
describe('lazy destructuring', () => {
|
|
5
5
|
it('supports tracked value getter and setter', async () => {
|
|
6
|
-
function Test() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<pre>{`${count.value}-${derived.value}`}</pre>
|
|
12
|
-
</>;
|
|
6
|
+
function Test() @{
|
|
7
|
+
let count = track(1);
|
|
8
|
+
let derived = track(() => count.value * 2);
|
|
9
|
+
count.value = 3;
|
|
10
|
+
<pre>{`${count.value}-${derived.value}`}</pre>
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
const { body } = await render(Test);
|
|
@@ -17,12 +15,12 @@ describe('lazy destructuring', () => {
|
|
|
17
15
|
});
|
|
18
16
|
|
|
19
17
|
it('lazily accesses object properties', async () => {
|
|
20
|
-
function Inner(&{ a, b }: { a: number; b: string }) {
|
|
21
|
-
|
|
18
|
+
function Inner(&{ a, b }: { a: number; b: string }) @{
|
|
19
|
+
<pre>{`${a}-${b}`}</pre>
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
function Test() {
|
|
25
|
-
|
|
22
|
+
function Test() @{
|
|
23
|
+
<Inner a={1} b="hello" />
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
const { body } = await render(Test);
|
|
@@ -30,12 +28,10 @@ describe('lazy destructuring', () => {
|
|
|
30
28
|
});
|
|
31
29
|
|
|
32
30
|
it('supports default values in lazy object destructuring', async () => {
|
|
33
|
-
function Test() {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
<pre>{`${a}-${b}`}</pre>
|
|
38
|
-
</>;
|
|
31
|
+
function Test() @{
|
|
32
|
+
const obj: { a: number; b?: number } = { a: 5 };
|
|
33
|
+
const &{ a, b = 99 } = obj;
|
|
34
|
+
<pre>{`${a}-${b}`}</pre>
|
|
39
35
|
}
|
|
40
36
|
|
|
41
37
|
const { body } = await render(Test);
|
|
@@ -43,15 +39,13 @@ describe('lazy destructuring', () => {
|
|
|
43
39
|
});
|
|
44
40
|
|
|
45
41
|
it('supports nested lazy destructuring in non-lazy component params', async () => {
|
|
46
|
-
function Inner({ something: &[first, second] }: { something: Tracked<number> }) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<pre>{`${first}-${second.value}`}</pre>
|
|
50
|
-
</>;
|
|
42
|
+
function Inner({ something: &[first, second] }: { something: Tracked<number> }) @{
|
|
43
|
+
first = second.value + 1;
|
|
44
|
+
<pre>{`${first}-${second.value}`}</pre>
|
|
51
45
|
}
|
|
52
46
|
|
|
53
|
-
function Test() {
|
|
54
|
-
|
|
47
|
+
function Test() @{
|
|
48
|
+
<Inner something={track(1)} />
|
|
55
49
|
}
|
|
56
50
|
|
|
57
51
|
const { body } = await render(Test);
|
|
@@ -59,14 +53,12 @@ describe('lazy destructuring', () => {
|
|
|
59
53
|
});
|
|
60
54
|
|
|
61
55
|
it('supports let lazy destructuring with assignment writeback', async () => {
|
|
62
|
-
function Test() {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
<pre>{`${obj.a}-${obj.b}`}</pre>
|
|
69
|
-
</>;
|
|
56
|
+
function Test() @{
|
|
57
|
+
const obj = { a: 1, b: 2 };
|
|
58
|
+
let &{ a, b } = obj;
|
|
59
|
+
a = 10;
|
|
60
|
+
b = 20;
|
|
61
|
+
<pre>{`${obj.a}-${obj.b}`}</pre>
|
|
70
62
|
}
|
|
71
63
|
|
|
72
64
|
const { body } = await render(Test);
|
|
@@ -74,14 +66,12 @@ describe('lazy destructuring', () => {
|
|
|
74
66
|
});
|
|
75
67
|
|
|
76
68
|
it('supports compound assignment operators on lazy bindings', async () => {
|
|
77
|
-
function Test() {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
<pre>{`${obj.a}-${obj.b}`}</pre>
|
|
84
|
-
</>;
|
|
69
|
+
function Test() @{
|
|
70
|
+
const obj = { a: 5, b: 10 };
|
|
71
|
+
let &{ a, b } = obj;
|
|
72
|
+
a += 3;
|
|
73
|
+
b *= 2;
|
|
74
|
+
<pre>{`${obj.a}-${obj.b}`}</pre>
|
|
85
75
|
}
|
|
86
76
|
|
|
87
77
|
const { body } = await render(Test);
|
|
@@ -89,15 +79,13 @@ describe('lazy destructuring', () => {
|
|
|
89
79
|
});
|
|
90
80
|
|
|
91
81
|
it('supports update expressions on lazy bindings', async () => {
|
|
92
|
-
function Test() {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
<pre>{obj.count}</pre>
|
|
100
|
-
</>;
|
|
82
|
+
function Test() @{
|
|
83
|
+
const obj = { count: 0 };
|
|
84
|
+
let &{ count } = obj;
|
|
85
|
+
count++;
|
|
86
|
+
count++;
|
|
87
|
+
count--;
|
|
88
|
+
<pre>{obj.count}</pre>
|
|
101
89
|
}
|
|
102
90
|
|
|
103
91
|
const { body } = await render(Test);
|
|
@@ -105,14 +93,12 @@ describe('lazy destructuring', () => {
|
|
|
105
93
|
});
|
|
106
94
|
|
|
107
95
|
it('supports update expressions on lazy bindings with default values', async () => {
|
|
108
|
-
function Test() {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
<pre>{obj.count}</pre>
|
|
115
|
-
</>;
|
|
96
|
+
function Test() @{
|
|
97
|
+
const obj: { count?: number } = {};
|
|
98
|
+
let &{ count = 0 } = obj;
|
|
99
|
+
count++;
|
|
100
|
+
count++;
|
|
101
|
+
<pre>{obj.count}</pre>
|
|
116
102
|
}
|
|
117
103
|
|
|
118
104
|
const { body } = await render(Test);
|
|
@@ -120,15 +106,13 @@ describe('lazy destructuring', () => {
|
|
|
120
106
|
});
|
|
121
107
|
|
|
122
108
|
it('supports function params with lazy destructuring and default values', async () => {
|
|
123
|
-
function Test() {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
<pre>{`${a}-${b}`}</pre>
|
|
131
|
-
</>;
|
|
109
|
+
function Test() @{
|
|
110
|
+
function calc(&{ x, y = 100 }: { x: number; y?: number }) {
|
|
111
|
+
return x + y;
|
|
112
|
+
}
|
|
113
|
+
const a = calc({ x: 5, y: 10 });
|
|
114
|
+
const b = calc({ x: 5 });
|
|
115
|
+
<pre>{`${a}-${b}`}</pre>
|
|
132
116
|
}
|
|
133
117
|
|
|
134
118
|
const { body } = await render(Test);
|
|
@@ -136,15 +120,13 @@ describe('lazy destructuring', () => {
|
|
|
136
120
|
});
|
|
137
121
|
|
|
138
122
|
it('supports nested lazy destructuring in non-lazy function params', async () => {
|
|
139
|
-
function Test() {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
<pre>{getInfo({ something })}</pre>
|
|
147
|
-
</>;
|
|
123
|
+
function Test() @{
|
|
124
|
+
const something = track(1);
|
|
125
|
+
function getInfo({ something: &[first, second] }: { something: Tracked<number> }) {
|
|
126
|
+
first = second.value + 1;
|
|
127
|
+
return `${first}-${second.value}`;
|
|
128
|
+
}
|
|
129
|
+
<pre>{getInfo({ something })}</pre>
|
|
148
130
|
}
|
|
149
131
|
|
|
150
132
|
const { body } = await render(Test);
|
|
@@ -158,16 +140,14 @@ describe('lazy destructuring', () => {
|
|
|
158
140
|
values: [head, ...&{ 0: first_rest, length: rest_length }],
|
|
159
141
|
}: {
|
|
160
142
|
values: number[];
|
|
161
|
-
}) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
<pre>{`${head}-${before}-${first_rest}-${rest_length}`}</pre>
|
|
166
|
-
</>;
|
|
143
|
+
}) @{
|
|
144
|
+
const before = `${first_rest}-${rest_length}`;
|
|
145
|
+
rest_length = 0;
|
|
146
|
+
<pre>{`${head}-${before}-${first_rest}-${rest_length}`}</pre>
|
|
167
147
|
}
|
|
168
148
|
|
|
169
|
-
function Test() {
|
|
170
|
-
|
|
149
|
+
function Test() @{
|
|
150
|
+
<Inner values={[10, 20, 30]} />
|
|
171
151
|
}
|
|
172
152
|
|
|
173
153
|
const { body } = await render(Test);
|
|
@@ -178,19 +158,17 @@ describe('lazy destructuring', () => {
|
|
|
178
158
|
it(
|
|
179
159
|
'preserves lazy getter/setter behavior for RestElement nested destructuring in non-lazy function params',
|
|
180
160
|
async () => {
|
|
181
|
-
function Test() {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
<pre>{getInfo({ values: [5, 6, 7] })}</pre>
|
|
193
|
-
</>;
|
|
161
|
+
function Test() @{
|
|
162
|
+
function getInfo({
|
|
163
|
+
values: [head, ...&{ 0: first_rest, length: rest_length }],
|
|
164
|
+
}: {
|
|
165
|
+
values: number[];
|
|
166
|
+
}) {
|
|
167
|
+
const before = `${first_rest}-${rest_length}`;
|
|
168
|
+
rest_length = 0;
|
|
169
|
+
return `${head}-${before}-${first_rest}-${rest_length}`;
|
|
170
|
+
}
|
|
171
|
+
<pre>{getInfo({ values: [5, 6, 7] })}</pre>
|
|
194
172
|
}
|
|
195
173
|
|
|
196
174
|
const { body } = await render(Test);
|
|
@@ -199,12 +177,10 @@ describe('lazy destructuring', () => {
|
|
|
199
177
|
);
|
|
200
178
|
|
|
201
179
|
it('supports member access on lazy destructured objects', async () => {
|
|
202
|
-
function Test() {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
<pre>{`${user.name}-${user.age}`}</pre>
|
|
207
|
-
</>;
|
|
180
|
+
function Test() @{
|
|
181
|
+
const obj = { user: { name: 'Alice', age: 30 } };
|
|
182
|
+
const &{ user } = obj;
|
|
183
|
+
<pre>{`${user.name}-${user.age}`}</pre>
|
|
208
184
|
}
|
|
209
185
|
|
|
210
186
|
const { body } = await render(Test);
|
|
@@ -212,12 +188,12 @@ describe('lazy destructuring', () => {
|
|
|
212
188
|
});
|
|
213
189
|
|
|
214
190
|
it('preserves numeric member access on lazy array value bindings', async () => {
|
|
215
|
-
function Child({ pair: &[first] }: { pair: [{ 0: string }] }) {
|
|
216
|
-
|
|
191
|
+
function Child({ pair: &[first] }: { pair: [{ 0: string }] }) @{
|
|
192
|
+
<pre>{first[0]}</pre>
|
|
217
193
|
}
|
|
218
194
|
|
|
219
|
-
function Test() {
|
|
220
|
-
|
|
195
|
+
function Test() @{
|
|
196
|
+
<Child pair={[{ 0: 'x' }]} />
|
|
221
197
|
}
|
|
222
198
|
|
|
223
199
|
const { body } = await render(Test);
|
|
@@ -225,12 +201,10 @@ describe('lazy destructuring', () => {
|
|
|
225
201
|
});
|
|
226
202
|
|
|
227
203
|
it('supports rest in lazy array destructuring for tracked tuples (iterable)', async () => {
|
|
228
|
-
function Test() {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
<pre>{`${value}-${rest.length}-${rest[0] === tracked_value}`}</pre>
|
|
233
|
-
</>;
|
|
204
|
+
function Test() @{
|
|
205
|
+
let tracked_value = track(0);
|
|
206
|
+
let &[value, ...rest] = tracked_value;
|
|
207
|
+
<pre>{`${value}-${rest.length}-${rest[0] === tracked_value}`}</pre>
|
|
234
208
|
}
|
|
235
209
|
|
|
236
210
|
const { body } = await render(Test);
|
|
@@ -238,12 +212,10 @@ describe('lazy destructuring', () => {
|
|
|
238
212
|
});
|
|
239
213
|
|
|
240
214
|
it('supports rest in lazy array destructuring for length-only array-like values', async () => {
|
|
241
|
-
function Test() {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
<pre>{`${first}-${rest.join('')}`}</pre>
|
|
246
|
-
</>;
|
|
215
|
+
function Test() @{
|
|
216
|
+
const array_like = { 0: 'x', 1: 'y', 2: 'z', length: 3 };
|
|
217
|
+
const &[first, ...rest] = array_like;
|
|
218
|
+
<pre>{`${first}-${rest.join('')}`}</pre>
|
|
247
219
|
}
|
|
248
220
|
|
|
249
221
|
const { body } = await render(Test);
|
|
@@ -251,18 +223,16 @@ describe('lazy destructuring', () => {
|
|
|
251
223
|
});
|
|
252
224
|
|
|
253
225
|
it('supports rest in lazy array destructuring for iterable values', async () => {
|
|
254
|
-
function Test() {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
<pre>{`${first}-${rest.join('')}`}</pre>
|
|
265
|
-
</>;
|
|
226
|
+
function Test() @{
|
|
227
|
+
const source = {
|
|
228
|
+
*[Symbol.iterator]() {
|
|
229
|
+
yield 'x';
|
|
230
|
+
yield 'y';
|
|
231
|
+
yield 'z';
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
const &[first, ...rest] = source;
|
|
235
|
+
<pre>{`${first}-${rest.join('')}`}</pre>
|
|
266
236
|
}
|
|
267
237
|
|
|
268
238
|
const { body } = await render(Test);
|
|
@@ -270,12 +240,10 @@ describe('lazy destructuring', () => {
|
|
|
270
240
|
});
|
|
271
241
|
|
|
272
242
|
it('supports standalone lazy array destructuring with track()', async () => {
|
|
273
|
-
function Test() {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
<div>{count}</div>
|
|
278
|
-
</>;
|
|
243
|
+
function Test() @{
|
|
244
|
+
let count;
|
|
245
|
+
&[count] = track(0);
|
|
246
|
+
<div>{count}</div>
|
|
279
247
|
}
|
|
280
248
|
|
|
281
249
|
const { body } = await render(Test);
|
|
@@ -283,16 +251,14 @@ describe('lazy destructuring', () => {
|
|
|
283
251
|
});
|
|
284
252
|
|
|
285
253
|
it('supports direct value access on tracked values during SSR', async () => {
|
|
286
|
-
function Test() {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
<pre>{`${value}-${ref === tracked}`}</pre>
|
|
295
|
-
</>;
|
|
254
|
+
function Test() @{
|
|
255
|
+
let tracked = track(0);
|
|
256
|
+
++tracked.value;
|
|
257
|
+
tracked.value++;
|
|
258
|
+
tracked.value = tracked.value + 1;
|
|
259
|
+
let value = tracked.value;
|
|
260
|
+
let ref = tracked;
|
|
261
|
+
<pre>{`${value}-${ref === tracked}`}</pre>
|
|
296
262
|
}
|
|
297
263
|
|
|
298
264
|
const { body } = await render(Test);
|
|
@@ -300,19 +266,15 @@ describe('lazy destructuring', () => {
|
|
|
300
266
|
});
|
|
301
267
|
|
|
302
268
|
it('supports lazy destructured tracked ref value access during SSR', async () => {
|
|
303
|
-
function Child({ pair: &[value, tracked_ref] }: { pair: Tracked<number> }) {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
<pre>{`${value}-${tracked_ref.value}`}</pre>
|
|
308
|
-
</>;
|
|
269
|
+
function Child({ pair: &[value, tracked_ref] }: { pair: Tracked<number> }) @{
|
|
270
|
+
++tracked_ref.value;
|
|
271
|
+
tracked_ref.value++;
|
|
272
|
+
<pre>{`${value}-${tracked_ref.value}`}</pre>
|
|
309
273
|
}
|
|
310
274
|
|
|
311
|
-
function Test() {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
<Child pair={tracked} />
|
|
315
|
-
</>;
|
|
275
|
+
function Test() @{
|
|
276
|
+
let tracked = track(0);
|
|
277
|
+
<Child pair={tracked} />
|
|
316
278
|
}
|
|
317
279
|
|
|
318
280
|
const { body } = await render(Test);
|
|
@@ -320,13 +282,11 @@ describe('lazy destructuring', () => {
|
|
|
320
282
|
});
|
|
321
283
|
|
|
322
284
|
it('supports standalone lazy object destructuring', async () => {
|
|
323
|
-
function Test() {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
<pre>{`${a}-${b}`}</pre>
|
|
329
|
-
</>;
|
|
285
|
+
function Test() @{
|
|
286
|
+
let a;
|
|
287
|
+
let b;
|
|
288
|
+
&{ a, b } = { a: 10, b: 20 };
|
|
289
|
+
<pre>{`${a}-${b}`}</pre>
|
|
330
290
|
}
|
|
331
291
|
|
|
332
292
|
const { body } = await render(Test);
|
|
@@ -337,23 +297,19 @@ describe('lazy destructuring', () => {
|
|
|
337
297
|
it('preserves nested lazy object access inside lazy object as component params', async () => {
|
|
338
298
|
let inner_value = 7;
|
|
339
299
|
|
|
340
|
-
function Inner(&{ outer: &{ inner } }: { outer: { inner: number } }) {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
<pre>{`${before}-${inner}`}</pre>
|
|
345
|
-
</>;
|
|
300
|
+
function Inner(&{ outer: &{ inner } }: { outer: { inner: number } }) @{
|
|
301
|
+
const before = inner;
|
|
302
|
+
inner_value = 8;
|
|
303
|
+
<pre>{`${before}-${inner}`}</pre>
|
|
346
304
|
}
|
|
347
305
|
|
|
348
|
-
function Test() {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
<Inner {outer} />
|
|
356
|
-
</>;
|
|
306
|
+
function Test() @{
|
|
307
|
+
const outer = {
|
|
308
|
+
get inner() {
|
|
309
|
+
return inner_value;
|
|
310
|
+
},
|
|
311
|
+
};
|
|
312
|
+
<Inner {outer} />
|
|
357
313
|
}
|
|
358
314
|
|
|
359
315
|
const { body } = await render(Test);
|
|
@@ -364,22 +320,18 @@ describe('lazy destructuring', () => {
|
|
|
364
320
|
let first_value = 3;
|
|
365
321
|
let second_value = 4;
|
|
366
322
|
|
|
367
|
-
function Inner({ pair: &[first, second] }: { pair: [number, number] }) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
<pre>{`${before}-${first}-${second}`}</pre>
|
|
373
|
-
</>;
|
|
323
|
+
function Inner({ pair: &[first, second] }: { pair: [number, number] }) @{
|
|
324
|
+
const before = `${first}-${second}`;
|
|
325
|
+
first_value = 5;
|
|
326
|
+
second_value = 6;
|
|
327
|
+
<pre>{`${before}-${first}-${second}`}</pre>
|
|
374
328
|
}
|
|
375
329
|
|
|
376
|
-
function Test() {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
<Inner {pair} />
|
|
382
|
-
</>;
|
|
330
|
+
function Test() @{
|
|
331
|
+
const pair = [0, 0] as [number, number];
|
|
332
|
+
Object.defineProperty(pair, 0, { get: () => first_value });
|
|
333
|
+
Object.defineProperty(pair, 1, { get: () => second_value });
|
|
334
|
+
<Inner {pair} />
|
|
383
335
|
}
|
|
384
336
|
|
|
385
337
|
const { body } = await render(Test);
|
|
@@ -387,21 +339,19 @@ describe('lazy destructuring', () => {
|
|
|
387
339
|
});
|
|
388
340
|
|
|
389
341
|
it('preserves nested lazy object access inside lazy array as function params', async () => {
|
|
390
|
-
function Test() {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
<pre>{getName([user])}</pre>
|
|
404
|
-
</>;
|
|
342
|
+
function Test() @{
|
|
343
|
+
let name_value = 'Alice';
|
|
344
|
+
function getName(&[&{ name }]: [{ name: string }]) {
|
|
345
|
+
const before = name;
|
|
346
|
+
name_value = 'Bob';
|
|
347
|
+
return `${before}-${name}`;
|
|
348
|
+
}
|
|
349
|
+
const user = {
|
|
350
|
+
get name() {
|
|
351
|
+
return name_value;
|
|
352
|
+
},
|
|
353
|
+
};
|
|
354
|
+
<pre>{getName([user])}</pre>
|
|
405
355
|
}
|
|
406
356
|
|
|
407
357
|
const { body } = await render(Test);
|
|
@@ -409,21 +359,19 @@ describe('lazy destructuring', () => {
|
|
|
409
359
|
});
|
|
410
360
|
|
|
411
361
|
it('preserves nested lazy array access inside lazy array as function params', async () => {
|
|
412
|
-
function Test() {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
<pre>{getValues([pair])}</pre>
|
|
426
|
-
</>;
|
|
362
|
+
function Test() @{
|
|
363
|
+
let first_value = 5;
|
|
364
|
+
let second_value = 6;
|
|
365
|
+
function getValues(&[&[a, b]]: [[number, number]]) {
|
|
366
|
+
const before = `${a}-${b}`;
|
|
367
|
+
first_value = 7;
|
|
368
|
+
second_value = 8;
|
|
369
|
+
return `${before}-${a}-${b}`;
|
|
370
|
+
}
|
|
371
|
+
const pair = [0, 0] as [number, number];
|
|
372
|
+
Object.defineProperty(pair, 0, { get: () => first_value });
|
|
373
|
+
Object.defineProperty(pair, 1, { get: () => second_value });
|
|
374
|
+
<pre>{getValues([pair])}</pre>
|
|
427
375
|
}
|
|
428
376
|
|
|
429
377
|
const { body } = await render(Test);
|
|
@@ -433,25 +381,21 @@ describe('lazy destructuring', () => {
|
|
|
433
381
|
it('preserves three-level lazy object access as component params', async () => {
|
|
434
382
|
let c_value = 42;
|
|
435
383
|
|
|
436
|
-
function Inner(&{ a: &{ b: &{ c } } }: { a: { b: { c: number } } }) {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
<pre>{`${before}-${c}`}</pre>
|
|
441
|
-
</>;
|
|
384
|
+
function Inner(&{ a: &{ b: &{ c } } }: { a: { b: { c: number } } }) @{
|
|
385
|
+
const before = c;
|
|
386
|
+
c_value = 43;
|
|
387
|
+
<pre>{`${before}-${c}`}</pre>
|
|
442
388
|
}
|
|
443
389
|
|
|
444
|
-
function Test() {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
return c_value;
|
|
450
|
-
},
|
|
390
|
+
function Test() @{
|
|
391
|
+
const a = {
|
|
392
|
+
b: {
|
|
393
|
+
get c() {
|
|
394
|
+
return c_value;
|
|
451
395
|
},
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
|
|
396
|
+
},
|
|
397
|
+
};
|
|
398
|
+
<Inner {a} />
|
|
455
399
|
}
|
|
456
400
|
|
|
457
401
|
const { body } = await render(Test);
|
|
@@ -459,21 +403,19 @@ describe('lazy destructuring', () => {
|
|
|
459
403
|
});
|
|
460
404
|
|
|
461
405
|
it('preserves nested lazy object access inside lazy object as function params', async () => {
|
|
462
|
-
function Test() {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
<pre>{getValue({ outer })}</pre>
|
|
476
|
-
</>;
|
|
406
|
+
function Test() @{
|
|
407
|
+
let inner_value = 11;
|
|
408
|
+
function getValue(&{ outer: &{ inner } }: { outer: { inner: number } }) {
|
|
409
|
+
const before = inner;
|
|
410
|
+
inner_value = 12;
|
|
411
|
+
return `${before}-${inner}`;
|
|
412
|
+
}
|
|
413
|
+
const outer = {
|
|
414
|
+
get inner() {
|
|
415
|
+
return inner_value;
|
|
416
|
+
},
|
|
417
|
+
};
|
|
418
|
+
<pre>{getValue({ outer })}</pre>
|
|
477
419
|
}
|
|
478
420
|
|
|
479
421
|
const { body } = await render(Test);
|
|
@@ -483,16 +425,14 @@ describe('lazy destructuring', () => {
|
|
|
483
425
|
it(
|
|
484
426
|
'supports nested lazy array inside lazy object as function params with writeback',
|
|
485
427
|
async () => {
|
|
486
|
-
function Test() {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
<pre>{`${obj.pair[0]}-${obj.pair[1]}`}</pre>
|
|
495
|
-
</>;
|
|
428
|
+
function Test() @{
|
|
429
|
+
const obj = { pair: [1, 2] as [number, number] };
|
|
430
|
+
function bump(&{ pair: &[first, second] }: { pair: [number, number] }) {
|
|
431
|
+
first = first + 10;
|
|
432
|
+
second = second + 20;
|
|
433
|
+
}
|
|
434
|
+
bump(obj);
|
|
435
|
+
<pre>{`${obj.pair[0]}-${obj.pair[1]}`}</pre>
|
|
496
436
|
}
|
|
497
437
|
|
|
498
438
|
const { body } = await render(Test);
|
|
@@ -501,23 +441,21 @@ describe('lazy destructuring', () => {
|
|
|
501
441
|
);
|
|
502
442
|
|
|
503
443
|
it('preserves three-level lazy object access as function params', async () => {
|
|
504
|
-
function Test() {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
return c_value;
|
|
516
|
-
},
|
|
444
|
+
function Test() @{
|
|
445
|
+
let c_value = 99;
|
|
446
|
+
function getValue(&{ a: &{ b: &{ c } } }: { a: { b: { c: number } } }) {
|
|
447
|
+
const before = c;
|
|
448
|
+
c_value = 100;
|
|
449
|
+
return `${before}-${c}`;
|
|
450
|
+
}
|
|
451
|
+
const a = {
|
|
452
|
+
b: {
|
|
453
|
+
get c() {
|
|
454
|
+
return c_value;
|
|
517
455
|
},
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
|
|
456
|
+
},
|
|
457
|
+
};
|
|
458
|
+
<pre>{getValue({ a })}</pre>
|
|
521
459
|
}
|
|
522
460
|
|
|
523
461
|
const { body } = await render(Test);
|
|
@@ -525,21 +463,19 @@ describe('lazy destructuring', () => {
|
|
|
525
463
|
});
|
|
526
464
|
|
|
527
465
|
it('preserves nested lazy object access inside lazy object in const declaration', async () => {
|
|
528
|
-
function Test() {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
return inner_value;
|
|
535
|
-
},
|
|
466
|
+
function Test() @{
|
|
467
|
+
let inner_value = 5;
|
|
468
|
+
const data = {
|
|
469
|
+
outer: {
|
|
470
|
+
get inner() {
|
|
471
|
+
return inner_value;
|
|
536
472
|
},
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
473
|
+
},
|
|
474
|
+
};
|
|
475
|
+
const &{ outer: &{ inner } } = data;
|
|
476
|
+
const before = inner;
|
|
477
|
+
inner_value = 6;
|
|
478
|
+
<pre>{`${before}-${inner}`}</pre>
|
|
543
479
|
}
|
|
544
480
|
|
|
545
481
|
const { body } = await render(Test);
|
|
@@ -547,13 +483,11 @@ describe('lazy destructuring', () => {
|
|
|
547
483
|
});
|
|
548
484
|
|
|
549
485
|
it('supports nested lazy object inside lazy object in let with writeback', async () => {
|
|
550
|
-
function Test() {
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
<pre>{data.outer.inner}</pre>
|
|
556
|
-
</>;
|
|
486
|
+
function Test() @{
|
|
487
|
+
const data = { outer: { inner: 5 } };
|
|
488
|
+
let &{ outer: &{ inner } } = data;
|
|
489
|
+
inner = 50;
|
|
490
|
+
<pre>{data.outer.inner}</pre>
|
|
557
491
|
}
|
|
558
492
|
|
|
559
493
|
const { body } = await render(Test);
|
|
@@ -561,14 +495,12 @@ describe('lazy destructuring', () => {
|
|
|
561
495
|
});
|
|
562
496
|
|
|
563
497
|
it('supports nested lazy array inside lazy object in let with writeback', async () => {
|
|
564
|
-
function Test() {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
<pre>{`${data.pair[0]}-${data.pair[1]}`}</pre>
|
|
571
|
-
</>;
|
|
498
|
+
function Test() @{
|
|
499
|
+
const data = { pair: [1, 2] as [number, number] };
|
|
500
|
+
let &{ pair: &[first, second] } = data;
|
|
501
|
+
first = 100;
|
|
502
|
+
second = 200;
|
|
503
|
+
<pre>{`${data.pair[0]}-${data.pair[1]}`}</pre>
|
|
572
504
|
}
|
|
573
505
|
|
|
574
506
|
const { body } = await render(Test);
|
|
@@ -576,13 +508,11 @@ describe('lazy destructuring', () => {
|
|
|
576
508
|
});
|
|
577
509
|
|
|
578
510
|
it('supports three-level lazy object nesting in let with writeback', async () => {
|
|
579
|
-
function Test() {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
<pre>{data.a.b.c}</pre>
|
|
585
|
-
</>;
|
|
511
|
+
function Test() @{
|
|
512
|
+
const data = { a: { b: { c: 1 } } };
|
|
513
|
+
let &{ a: &{ b: &{ c } } } = data;
|
|
514
|
+
c = 999;
|
|
515
|
+
<pre>{data.a.b.c}</pre>
|
|
586
516
|
}
|
|
587
517
|
|
|
588
518
|
const { body } = await render(Test);
|
|
@@ -590,14 +520,12 @@ describe('lazy destructuring', () => {
|
|
|
590
520
|
});
|
|
591
521
|
|
|
592
522
|
it('supports compound assignment on deeply nested lazy bindings', async () => {
|
|
593
|
-
function Test() {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
<pre>{data.a.b.c}</pre>
|
|
600
|
-
</>;
|
|
523
|
+
function Test() @{
|
|
524
|
+
const data = { a: { b: { c: 5 } } };
|
|
525
|
+
let &{ a: &{ b: &{ c } } } = data;
|
|
526
|
+
c += 10;
|
|
527
|
+
c *= 2;
|
|
528
|
+
<pre>{data.a.b.c}</pre>
|
|
601
529
|
}
|
|
602
530
|
|
|
603
531
|
const { body } = await render(Test);
|
|
@@ -605,21 +533,19 @@ describe('lazy destructuring', () => {
|
|
|
605
533
|
});
|
|
606
534
|
|
|
607
535
|
it('preserves default values inside nested lazy destructuring', async () => {
|
|
608
|
-
function Test() {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
return inner_value;
|
|
615
|
-
},
|
|
536
|
+
function Test() @{
|
|
537
|
+
let inner_value: number | undefined;
|
|
538
|
+
const data: { outer: { inner?: number } } = {
|
|
539
|
+
outer: {
|
|
540
|
+
get inner() {
|
|
541
|
+
return inner_value;
|
|
616
542
|
},
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
543
|
+
},
|
|
544
|
+
};
|
|
545
|
+
const &{ outer: &{ inner = 42 } } = data;
|
|
546
|
+
const before = inner;
|
|
547
|
+
inner_value = 43;
|
|
548
|
+
<pre>{`${before}-${inner}`}</pre>
|
|
623
549
|
}
|
|
624
550
|
|
|
625
551
|
const { body } = await render(Test);
|
|
@@ -627,28 +553,26 @@ describe('lazy destructuring', () => {
|
|
|
627
553
|
});
|
|
628
554
|
|
|
629
555
|
it('preserves multiple sibling nested lazy destructures', async () => {
|
|
630
|
-
function Test() {
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
return x_value;
|
|
638
|
-
},
|
|
556
|
+
function Test() @{
|
|
557
|
+
let x_value = 1;
|
|
558
|
+
let y_value = 2;
|
|
559
|
+
const data = {
|
|
560
|
+
a: {
|
|
561
|
+
get x() {
|
|
562
|
+
return x_value;
|
|
639
563
|
},
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
564
|
+
},
|
|
565
|
+
b: {
|
|
566
|
+
get y() {
|
|
567
|
+
return y_value;
|
|
644
568
|
},
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
569
|
+
},
|
|
570
|
+
};
|
|
571
|
+
const &{ a: &{ x }, b: &{ y } } = data;
|
|
572
|
+
const before = `${x}-${y}`;
|
|
573
|
+
x_value = 3;
|
|
574
|
+
y_value = 4;
|
|
575
|
+
<pre>{`${before}-${x}-${y}`}</pre>
|
|
652
576
|
}
|
|
653
577
|
|
|
654
578
|
const { body } = await render(Test);
|
|
@@ -656,14 +580,12 @@ describe('lazy destructuring', () => {
|
|
|
656
580
|
});
|
|
657
581
|
|
|
658
582
|
it('supports multiple sibling nested lazy destructures with writeback', async () => {
|
|
659
|
-
function Test() {
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
<pre>{`${data.a.x}-${data.b.y}`}</pre>
|
|
666
|
-
</>;
|
|
583
|
+
function Test() @{
|
|
584
|
+
const data = { a: { x: 1 }, b: { y: 2 } };
|
|
585
|
+
let &{ a: &{ x }, b: &{ y } } = data;
|
|
586
|
+
x = 11;
|
|
587
|
+
y = 22;
|
|
588
|
+
<pre>{`${data.a.x}-${data.b.y}`}</pre>
|
|
667
589
|
}
|
|
668
590
|
|
|
669
591
|
const { body } = await render(Test);
|