ripple 0.3.68 → 0.3.69
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 +48 -0
- package/package.json +3 -3
- package/src/jsx-runtime.d.ts +2 -2
- package/src/runtime/element.js +1 -1
- package/src/runtime/index-client.js +11 -11
- package/src/runtime/index-server.js +7 -4
- package/src/runtime/internal/client/bindings.js +1 -1
- package/src/runtime/internal/client/blocks.js +13 -4
- package/src/runtime/internal/client/component.js +55 -0
- package/src/runtime/internal/client/composite.js +4 -2
- package/src/runtime/internal/client/expression.js +65 -7
- package/src/runtime/internal/client/hmr.js +54 -43
- package/src/runtime/internal/client/index.js +5 -1
- package/src/runtime/internal/client/portal.js +70 -69
- package/src/runtime/internal/client/render.js +3 -0
- package/src/runtime/internal/server/index.js +92 -8
- package/tests/client/__snapshots__/html.test.tsrx.snap +3 -3
- package/tests/client/array/array.copy-within.test.tsrx +33 -31
- package/tests/client/array/array.derived.test.tsrx +186 -169
- package/tests/client/array/array.iteration.test.tsrx +40 -37
- package/tests/client/array/array.mutations.test.tsrx +113 -101
- package/tests/client/array/array.static.test.tsrx +119 -101
- package/tests/client/array/array.to-methods.test.tsrx +24 -21
- package/tests/client/async-suspend.test.tsrx +247 -246
- package/tests/client/basic/__snapshots__/basic.rendering.test.tsrx.snap +0 -1
- package/tests/client/basic/basic.attributes.test.tsrx +428 -423
- package/tests/client/basic/basic.collections.test.tsrx +109 -102
- package/tests/client/basic/basic.components.test.tsrx +323 -205
- package/tests/client/basic/basic.errors.test.tsrx +91 -91
- package/tests/client/basic/basic.events.test.tsrx +114 -115
- package/tests/client/basic/basic.get-set.test.tsrx +97 -87
- package/tests/client/basic/basic.hmr.test.tsrx +19 -16
- package/tests/client/basic/basic.reactivity.test.tsrx +199 -191
- package/tests/client/basic/basic.rendering.test.tsrx +272 -182
- package/tests/client/basic/basic.styling.test.tsrx +23 -22
- package/tests/client/basic/basic.utilities.test.tsrx +10 -8
- package/tests/client/boundaries.test.tsrx +26 -26
- package/tests/client/compiler/__snapshots__/compiler.assignments.test.rsrx.snap +5 -5
- package/tests/client/compiler/__snapshots__/compiler.assignments.test.tsrx.snap +5 -5
- package/tests/client/compiler/compiler.assignments.test.tsrx +77 -81
- package/tests/client/compiler/compiler.attributes.test.tsrx +15 -15
- package/tests/client/compiler/compiler.basic.test.tsrx +322 -314
- package/tests/client/compiler/compiler.regex.test.tsrx +44 -47
- package/tests/client/compiler/compiler.tracked-access.test.tsrx +38 -38
- package/tests/client/compiler/compiler.try-in-function.test.tsrx +16 -16
- package/tests/client/compiler/compiler.typescript.test.tsrx +2 -2
- package/tests/client/composite/composite.dynamic-components.test.tsrx +47 -48
- package/tests/client/composite/composite.generics.test.tsrx +168 -192
- package/tests/client/composite/composite.props.test.tsrx +97 -81
- package/tests/client/composite/composite.reactivity.test.tsrx +177 -147
- package/tests/client/composite/composite.render.test.tsrx +122 -105
- package/tests/client/computed-properties.test.tsrx +28 -28
- package/tests/client/context.test.tsrx +21 -21
- package/tests/client/css/global-additional-cases.test.tsrx +58 -58
- package/tests/client/css/global-advanced-selectors.test.tsrx +16 -16
- package/tests/client/css/global-at-rules.test.tsrx +10 -10
- package/tests/client/css/global-basic.test.tsrx +14 -14
- package/tests/client/css/global-classes-ids.test.tsrx +14 -14
- package/tests/client/css/global-combinators.test.tsrx +10 -10
- package/tests/client/css/global-complex-nesting.test.tsrx +14 -14
- package/tests/client/css/global-edge-cases.test.tsrx +18 -18
- package/tests/client/css/global-keyframes.test.tsrx +12 -12
- package/tests/client/css/global-nested.test.tsrx +10 -10
- package/tests/client/css/global-pseudo.test.tsrx +12 -12
- package/tests/client/css/global-scoping.test.tsrx +20 -20
- package/tests/client/css/style-identifier.test.tsrx +143 -291
- package/tests/client/date.test.tsrx +146 -133
- package/tests/client/dynamic-elements.test.tsrx +398 -365
- package/tests/client/events.test.tsrx +292 -290
- package/tests/client/for.test.tsrx +156 -153
- package/tests/client/head.test.tsrx +105 -96
- package/tests/client/html.test.tsrx +122 -26
- package/tests/client/input-value.test.tsrx +1361 -1314
- package/tests/client/lazy-array.test.tsrx +16 -13
- package/tests/client/lazy-destructuring.test.tsrx +257 -213
- package/tests/client/map.test.tsrx +65 -60
- package/tests/client/media-query.test.tsrx +22 -20
- package/tests/client/object.test.tsrx +87 -81
- package/tests/client/portal.test.tsrx +57 -51
- package/tests/client/ref.test.tsrx +233 -202
- package/tests/client/return.test.tsrx +71 -2560
- package/tests/client/set.test.tsrx +54 -45
- package/tests/client/svg.test.tsrx +216 -186
- package/tests/client/switch.test.tsrx +194 -193
- package/tests/client/track-async-hydration.test.tsrx +18 -14
- package/tests/client/tracked-index-access.test.tsrx +28 -18
- package/tests/client/try.test.tsrx +675 -548
- package/tests/client/tsx.test.tsrx +373 -311
- package/tests/client/typescript-generics.test.tsrx +145 -145
- package/tests/client/url/url.derived.test.tsrx +33 -28
- package/tests/client/url/url.parsing.test.tsrx +61 -51
- package/tests/client/url/url.partial-removal.test.tsrx +56 -48
- package/tests/client/url/url.reactivity.test.tsrx +142 -125
- package/tests/client/url/url.serialization.test.tsrx +13 -11
- package/tests/client/url-search-params/url-search-params.derived.test.tsrx +34 -29
- package/tests/client/url-search-params/url-search-params.initialization.test.tsrx +25 -21
- package/tests/client/url-search-params/url-search-params.iteration.test.tsrx +50 -45
- package/tests/client/url-search-params/url-search-params.mutation.test.tsrx +111 -99
- package/tests/client/url-search-params/url-search-params.retrieval.test.tsrx +49 -43
- package/tests/client/url-search-params/url-search-params.serialization.test.tsrx +14 -12
- package/tests/client/url-search-params/url-search-params.tracked-url.test.tsrx +16 -14
- package/tests/hydration/basic.test.js +3 -3
- package/tests/hydration/compiled/client/basic.js +586 -651
- package/tests/hydration/compiled/client/composite.js +79 -104
- package/tests/hydration/compiled/client/events.js +140 -148
- package/tests/hydration/compiled/client/for.js +1005 -1018
- package/tests/hydration/compiled/client/head.js +124 -134
- package/tests/hydration/compiled/client/hmr.js +41 -48
- package/tests/hydration/compiled/client/html-in-template.js +38 -41
- package/tests/hydration/compiled/client/html.js +970 -1314
- package/tests/hydration/compiled/client/if-children.js +234 -249
- package/tests/hydration/compiled/client/if.js +182 -189
- package/tests/hydration/compiled/client/mixed-control-flow.js +347 -303
- package/tests/hydration/compiled/client/nested-control-flow.js +1084 -832
- package/tests/hydration/compiled/client/portal.js +65 -85
- package/tests/hydration/compiled/client/reactivity.js +84 -90
- package/tests/hydration/compiled/client/return.js +38 -1939
- package/tests/hydration/compiled/client/switch.js +218 -224
- package/tests/hydration/compiled/client/track-async-serialization.js +250 -259
- package/tests/hydration/compiled/client/try.js +123 -132
- package/tests/hydration/compiled/server/basic.js +773 -831
- package/tests/hydration/compiled/server/composite.js +166 -191
- package/tests/hydration/compiled/server/events.js +170 -184
- package/tests/hydration/compiled/server/for.js +851 -909
- package/tests/hydration/compiled/server/head.js +206 -216
- package/tests/hydration/compiled/server/hmr.js +64 -72
- package/tests/hydration/compiled/server/html-in-template.js +42 -76
- package/tests/hydration/compiled/server/html.js +1362 -1667
- package/tests/hydration/compiled/server/if-children.js +419 -445
- package/tests/hydration/compiled/server/if.js +194 -208
- package/tests/hydration/compiled/server/mixed-control-flow.js +249 -257
- package/tests/hydration/compiled/server/nested-control-flow.js +491 -515
- package/tests/hydration/compiled/server/portal.js +152 -160
- package/tests/hydration/compiled/server/reactivity.js +94 -106
- package/tests/hydration/compiled/server/return.js +28 -2172
- package/tests/hydration/compiled/server/switch.js +274 -286
- package/tests/hydration/compiled/server/track-async-serialization.js +340 -358
- package/tests/hydration/compiled/server/try.js +167 -185
- package/tests/hydration/components/basic.tsrx +320 -272
- package/tests/hydration/components/composite.tsrx +44 -32
- package/tests/hydration/components/events.tsrx +101 -91
- package/tests/hydration/components/for.tsrx +510 -452
- package/tests/hydration/components/head.tsrx +87 -80
- package/tests/hydration/components/hmr.tsrx +22 -17
- package/tests/hydration/components/html-in-template.tsrx +22 -17
- package/tests/hydration/components/html.tsrx +525 -443
- package/tests/hydration/components/if-children.tsrx +158 -148
- package/tests/hydration/components/if.tsrx +109 -95
- package/tests/hydration/components/mixed-control-flow.tsrx +100 -96
- package/tests/hydration/components/nested-control-flow.tsrx +215 -203
- package/tests/hydration/components/portal.tsrx +41 -34
- package/tests/hydration/components/reactivity.tsrx +37 -27
- package/tests/hydration/components/return.tsrx +12 -556
- package/tests/hydration/components/switch.tsrx +120 -114
- package/tests/hydration/components/track-async-serialization.tsrx +107 -91
- package/tests/hydration/components/try.tsrx +55 -40
- package/tests/hydration/html.test.js +4 -4
- package/tests/hydration/return.test.js +13 -532
- package/tests/server/await.test.tsrx +3 -3
- package/tests/server/basic.attributes.test.tsrx +264 -195
- package/tests/server/basic.components.test.tsrx +296 -169
- package/tests/server/basic.test.tsrx +300 -198
- package/tests/server/compiler.test.tsrx +62 -60
- package/tests/server/composite.props.test.tsrx +77 -63
- package/tests/server/composite.test.tsrx +168 -192
- package/tests/server/context.test.tsrx +18 -12
- package/tests/server/dynamic-elements.test.tsrx +197 -180
- package/tests/server/for.test.tsrx +85 -78
- package/tests/server/head.test.tsrx +50 -43
- package/tests/server/html-nesting-validation.test.tsrx +8 -8
- package/tests/server/if.test.tsrx +57 -51
- package/tests/server/lazy-destructuring.test.tsrx +366 -294
- package/tests/server/return.test.tsrx +76 -1355
- package/tests/server/streaming-ssr.test.tsrx +4 -75
- package/tests/server/style-identifier.test.tsrx +169 -148
- package/tests/server/switch.test.tsrx +91 -85
- package/tests/server/track-async-serialization.test.tsrx +105 -85
- package/tests/server/try.test.tsrx +374 -280
- package/tests/utils/compiler-compat-config.test.js +2 -2
- package/tests/utils/runtime-imports.test.js +10 -0
- package/types/index.d.ts +8 -0
- package/tests/client/__snapshots__/html.test.rsrx.snap +0 -40
|
@@ -2,25 +2,25 @@ import { flushSync, track } from 'ripple';
|
|
|
2
2
|
|
|
3
3
|
describe('switch statements', () => {
|
|
4
4
|
it('renders simple switch with literal cases', () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
function App() {
|
|
6
|
+
return <>
|
|
7
|
+
let &[value] = track('b');
|
|
8
|
+
<button onClick={() => (value = 'c')}>{'Change to C'}</button>
|
|
9
|
+
<button onClick={() => (value = 'a')}>{'Change to A'}</button>
|
|
10
|
+
switch (value) {
|
|
11
|
+
case 'a':
|
|
12
|
+
<div>{'Case A'}</div>
|
|
13
|
+
break;
|
|
14
|
+
case 'b':
|
|
15
|
+
<div>{'Case B'}</div>
|
|
16
|
+
break;
|
|
17
|
+
case 'c':
|
|
18
|
+
<div>{'Case C'}</div>
|
|
19
|
+
break;
|
|
20
|
+
default:
|
|
21
|
+
<div>{'Default Case'}</div>
|
|
22
|
+
}
|
|
23
|
+
</>;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
render(App);
|
|
@@ -37,21 +37,21 @@ describe('switch statements', () => {
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
it('renders switch with reactive discriminant', () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
40
|
+
function App() {
|
|
41
|
+
return <>
|
|
42
|
+
let &[count] = track(1);
|
|
43
|
+
<button onClick={() => count++}>{'Increment'}</button>
|
|
44
|
+
switch (count) {
|
|
45
|
+
case 1:
|
|
46
|
+
<div>{'Count is 1'}</div>
|
|
47
|
+
break;
|
|
48
|
+
case 2:
|
|
49
|
+
<div>{'Count is 2'}</div>
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
<div>{'Count is other'}</div>
|
|
53
|
+
}
|
|
54
|
+
</>;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
render(App);
|
|
@@ -69,15 +69,15 @@ describe('switch statements', () => {
|
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
it('renders switch with default clause only', () => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
function App() {
|
|
73
|
+
return <>
|
|
74
|
+
let &[value] = track('x');
|
|
75
|
+
<button onClick={() => (value = 'y')}>{'Change Value'}</button>
|
|
76
|
+
switch (value) {
|
|
77
|
+
default:
|
|
78
|
+
<div>{'Default for ' + value}</div>
|
|
79
|
+
}
|
|
80
|
+
</>;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
render(App);
|
|
@@ -90,23 +90,23 @@ describe('switch statements', () => {
|
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
it('renders switch using empty case fall-through', () => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
93
|
+
function App() {
|
|
94
|
+
return <>
|
|
95
|
+
let &[value] = track('a');
|
|
96
|
+
<button onClick={() => (value = 'b')}>{'Change to B'}</button>
|
|
97
|
+
<button onClick={() => (value = 'c')}>{'Change to C'}</button>
|
|
98
|
+
switch (value) {
|
|
99
|
+
case 'a':
|
|
100
|
+
<div>{'Case A'}</div>
|
|
101
|
+
break;
|
|
102
|
+
case 'b':
|
|
103
|
+
case 'c':
|
|
104
|
+
<div>{'Case B or C'}</div>
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
<div>{'Default Case'}</div>
|
|
108
|
+
}
|
|
109
|
+
</>;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
render(App);
|
|
@@ -132,31 +132,31 @@ describe('switch statements', () => {
|
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
it('renders switch with template content and reacts to tracked changes', () => {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
135
|
+
function App() {
|
|
136
|
+
return <>
|
|
137
|
+
let &[status] = track('active');
|
|
138
|
+
let &[message] = track('');
|
|
139
|
+
<button onClick={() => (status = 'pending')}>{'Pending'}</button>
|
|
140
|
+
<button onClick={() => (status = 'completed')}>{'Completed'}</button>
|
|
141
|
+
<button onClick={() => (status = 'error')}>{'Error'}</button>
|
|
142
|
+
switch (status) {
|
|
143
|
+
case 'active':
|
|
144
|
+
message = 'Currently active.';
|
|
145
|
+
<div>{'Status: ' + message}</div>
|
|
146
|
+
break;
|
|
147
|
+
case 'pending':
|
|
148
|
+
message = 'Waiting for completion.';
|
|
149
|
+
<div>{'Status: ' + message}</div>
|
|
150
|
+
break;
|
|
151
|
+
case 'completed':
|
|
152
|
+
message = 'Task finished!';
|
|
153
|
+
<div class="success">{'Status: ' + message}</div>
|
|
154
|
+
break;
|
|
155
|
+
default:
|
|
156
|
+
message = 'An error occurred.';
|
|
157
|
+
<div class="error">{'Status: ' + message}</div>
|
|
158
|
+
}
|
|
159
|
+
</>;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
render(App);
|
|
@@ -184,35 +184,37 @@ describe('switch statements', () => {
|
|
|
184
184
|
it(
|
|
185
185
|
'renders switch with multiple non-empty fall-through cases and reacts to tracked changes without recreating DOM unnecessarily',
|
|
186
186
|
() => {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
187
|
+
function App() {
|
|
188
|
+
return <>
|
|
189
|
+
let &[status] = track(0);
|
|
190
|
+
<div>
|
|
191
|
+
switch (status) {
|
|
192
|
+
case -1:
|
|
193
|
+
case 0:
|
|
194
|
+
<p>{' Idle'}</p>
|
|
195
|
+
case 1:
|
|
196
|
+
<p>{' Loading'}</p>
|
|
197
|
+
case 2:
|
|
198
|
+
<p>{' Success'}</p>
|
|
199
|
+
break;
|
|
200
|
+
default:
|
|
201
|
+
<p>{' Unknown status'}</p>
|
|
202
|
+
<p>{' Unknown 2'}</p>
|
|
203
|
+
case 3:
|
|
204
|
+
<p>{' Error'}</p>
|
|
205
|
+
<p>{' Error 2'}</p>
|
|
206
|
+
<p>{' Error 3'}</p>
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
</div>
|
|
210
|
+
<button
|
|
211
|
+
onClick={() => {
|
|
212
|
+
status = (status + 1) % 5;
|
|
213
|
+
}}
|
|
214
|
+
>
|
|
215
|
+
{'Next Status'}
|
|
216
|
+
</button>
|
|
217
|
+
</>;
|
|
216
218
|
}
|
|
217
219
|
|
|
218
220
|
render(App);
|
|
@@ -252,33 +254,33 @@ describe('switch statements', () => {
|
|
|
252
254
|
it(
|
|
253
255
|
'renders a fall-through default in the middle of switch cases and reacts to changes without recreating DOM unnecessarily',
|
|
254
256
|
() => {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
257
|
+
function App() {
|
|
258
|
+
return <>
|
|
259
|
+
let &[value] = track('x');
|
|
260
|
+
<button onClick={() => (value = 'a')}>{'Set A'}</button>
|
|
261
|
+
<button onClick={() => (value = 'b')}>{'Set B'}</button>
|
|
262
|
+
<button onClick={() => (value = 'c')}>{'Set C'}</button>
|
|
263
|
+
<button onClick={() => (value = 'x')}>{'Set X'}</button>
|
|
264
|
+
<div>
|
|
265
|
+
switch (value) {
|
|
266
|
+
case 'a':
|
|
267
|
+
<div>{' Case A'}</div>
|
|
268
|
+
break;
|
|
269
|
+
// NOTE: This should be the default in the middle of the cases
|
|
270
|
+
// However, jsdom (and other node-based dom libs) has a bug
|
|
271
|
+
// that breaks out of the switch even if the default doesn't have a break
|
|
272
|
+
// The browser works correctly.
|
|
273
|
+
// So, we're just using a defined case in the middle to simulate default.
|
|
274
|
+
case 'x':
|
|
275
|
+
<div>{' Default Case for ' + value}</div>
|
|
276
|
+
case 'b':
|
|
277
|
+
<div>{' Case B'}</div>
|
|
278
|
+
break;
|
|
279
|
+
case 'c':
|
|
280
|
+
<div>{' Case C'}</div>
|
|
281
|
+
}
|
|
282
|
+
</div>
|
|
283
|
+
</>;
|
|
282
284
|
}
|
|
283
285
|
|
|
284
286
|
render(App);
|
|
@@ -318,18 +320,19 @@ describe('switch statements', () => {
|
|
|
318
320
|
);
|
|
319
321
|
|
|
320
322
|
it('renders bare text nodes in switch fall-through cases without element wrappers', () => {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
323
|
+
function App() {
|
|
324
|
+
return <>
|
|
325
|
+
let value = 'a';
|
|
326
|
+
<div>
|
|
327
|
+
<span>{'before'}</span>
|
|
328
|
+
switch (value) {
|
|
329
|
+
case 'a':
|
|
330
|
+
{'Case A'}
|
|
331
|
+
case 'b':
|
|
332
|
+
{'Case B'}
|
|
333
|
+
}
|
|
334
|
+
</div>
|
|
335
|
+
</>;
|
|
333
336
|
}
|
|
334
337
|
|
|
335
338
|
render(App);
|
|
@@ -337,20 +340,21 @@ describe('switch statements', () => {
|
|
|
337
340
|
});
|
|
338
341
|
|
|
339
342
|
it('renders bare text nodes in switch cases without element wrappers', () => {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
343
|
+
function App() {
|
|
344
|
+
return <>
|
|
345
|
+
let value = 'a';
|
|
346
|
+
<div>
|
|
347
|
+
<span>{'before'}</span>
|
|
348
|
+
switch (value) {
|
|
349
|
+
case 'a':
|
|
350
|
+
{'Case A'}
|
|
351
|
+
break;
|
|
352
|
+
case 'b':
|
|
353
|
+
{'Case B'}
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
</div>
|
|
357
|
+
</>;
|
|
354
358
|
}
|
|
355
359
|
|
|
356
360
|
render(App);
|
|
@@ -358,33 +362,30 @@ describe('switch statements', () => {
|
|
|
358
362
|
});
|
|
359
363
|
|
|
360
364
|
it('renders switch with block-scoped cases and break inside blocks', () => {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
case 3: {
|
|
384
|
-
<div class="level">{'Level 3'}</div>
|
|
385
|
-
break;
|
|
365
|
+
function App() {
|
|
366
|
+
return <>
|
|
367
|
+
let &[level] = track(1);
|
|
368
|
+
<button
|
|
369
|
+
onClick={() => {
|
|
370
|
+
if (level === 1) level = 2;
|
|
371
|
+
else if (level === 2) level = 3;
|
|
372
|
+
else level = 1;
|
|
373
|
+
}}
|
|
374
|
+
>
|
|
375
|
+
{'Toggle'}
|
|
376
|
+
</button>
|
|
377
|
+
switch (level) {
|
|
378
|
+
case 1:
|
|
379
|
+
<div class="level">{'Level 1'}</div>
|
|
380
|
+
break;
|
|
381
|
+
case 2:
|
|
382
|
+
<div class="level">{'Level 2'}</div>
|
|
383
|
+
break;
|
|
384
|
+
case 3:
|
|
385
|
+
<div class="level">{'Level 3'}</div>
|
|
386
|
+
break;
|
|
386
387
|
}
|
|
387
|
-
|
|
388
|
+
</>;
|
|
388
389
|
}
|
|
389
390
|
|
|
390
391
|
render(App);
|
|
@@ -5,13 +5,15 @@ describe('trackAsync hydration from serialized data (client)', () => {
|
|
|
5
5
|
// This test verifies the client runtime can parse the serialized script tags
|
|
6
6
|
// The full hydration round-trip is tested in hydration tests
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
function App() {
|
|
9
|
+
return <>
|
|
10
|
+
try {
|
|
11
|
+
let &[data] = trackAsync(() => Promise.resolve('fallback'));
|
|
12
|
+
<p class="result">{data}</p>
|
|
13
|
+
} pending {
|
|
14
|
+
<p class="loading">{'loading...'}</p>
|
|
15
|
+
}
|
|
16
|
+
</>;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
render(App);
|
|
@@ -29,13 +31,15 @@ describe('trackAsync hydration from serialized data (client)', () => {
|
|
|
29
31
|
let resolve_fn: (value: number) => void;
|
|
30
32
|
const promise = new Promise<number>((r) => (resolve_fn = r));
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
function App() {
|
|
35
|
+
return <>
|
|
36
|
+
try {
|
|
37
|
+
let &[value] = trackAsync(() => promise);
|
|
38
|
+
<span class="value">{value}</span>
|
|
39
|
+
} pending {
|
|
40
|
+
<span class="pending">{'waiting'}</span>
|
|
41
|
+
}
|
|
42
|
+
</>;
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
render(App);
|
|
@@ -15,9 +15,11 @@ describe('client tracked numeric access', () => {
|
|
|
15
15
|
it('throws when tracked values are accessed through numeric properties', () => {
|
|
16
16
|
let value: any;
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
function Test() {
|
|
19
|
+
return <>
|
|
20
|
+
value = track(0);
|
|
21
|
+
<div />
|
|
22
|
+
</>;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
render(Test);
|
|
@@ -32,9 +34,11 @@ describe('client tracked numeric access', () => {
|
|
|
32
34
|
it('throws when derived values are accessed through numeric properties', () => {
|
|
33
35
|
let value: any;
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
function Test() {
|
|
38
|
+
return <>
|
|
39
|
+
value = track(() => 1);
|
|
40
|
+
<div />
|
|
41
|
+
</>;
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
render(Test);
|
|
@@ -50,10 +54,12 @@ describe('client tracked numeric access', () => {
|
|
|
50
54
|
let value: any;
|
|
51
55
|
let next: any;
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
function Test() {
|
|
58
|
+
return <>
|
|
59
|
+
value = track(0);
|
|
60
|
+
next = track(1);
|
|
61
|
+
<div />
|
|
62
|
+
</>;
|
|
57
63
|
}
|
|
58
64
|
|
|
59
65
|
render(Test);
|
|
@@ -72,10 +78,12 @@ describe('client tracked numeric access', () => {
|
|
|
72
78
|
let value: any;
|
|
73
79
|
let derived: any;
|
|
74
80
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
function Test() {
|
|
82
|
+
return <>
|
|
83
|
+
value = track(0);
|
|
84
|
+
derived = track(() => value.value + 1);
|
|
85
|
+
<div />
|
|
86
|
+
</>;
|
|
79
87
|
}
|
|
80
88
|
|
|
81
89
|
render(Test);
|
|
@@ -92,10 +100,12 @@ describe('client tracked numeric access', () => {
|
|
|
92
100
|
let value: any;
|
|
93
101
|
let derived: any;
|
|
94
102
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
function Test() {
|
|
104
|
+
return <>
|
|
105
|
+
value = track(0);
|
|
106
|
+
derived = track(() => value.value + 1);
|
|
107
|
+
<div />
|
|
108
|
+
</>;
|
|
99
109
|
}
|
|
100
110
|
|
|
101
111
|
render(Test);
|