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
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
describe('for statements in SSR', () => {
|
|
2
2
|
it('renders a simple static array', async () => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
function App() {
|
|
4
|
+
return <>
|
|
5
|
+
const items = ['Item 1', 'Item 2', 'Item 3'];
|
|
6
|
+
for (const item of items) {
|
|
7
|
+
<div class={item}>{item}</div>
|
|
8
|
+
}
|
|
9
|
+
</>;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
const { body } = await render(App);
|
|
@@ -15,26 +16,27 @@ describe('for statements in SSR', () => {
|
|
|
15
16
|
});
|
|
16
17
|
|
|
17
18
|
it('renders nested for...of loops', async () => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
19
|
+
function App() {
|
|
20
|
+
return <>
|
|
21
|
+
const groups = [
|
|
22
|
+
{
|
|
23
|
+
name: 'Group 1',
|
|
24
|
+
items: ['Item 1.1', 'Item 1.2'],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'Group 2',
|
|
28
|
+
items: ['Item 2.1', 'Item 2.2'],
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
for (const group of groups) {
|
|
32
|
+
<h1>{group.name}</h1>
|
|
33
|
+
<ul>
|
|
34
|
+
for (const item of group.items) {
|
|
35
|
+
<li>{item}</li>
|
|
36
|
+
}
|
|
37
|
+
</ul>
|
|
38
|
+
}
|
|
39
|
+
</>;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
const { body } = await render(App);
|
|
@@ -44,12 +46,13 @@ describe('for statements in SSR', () => {
|
|
|
44
46
|
});
|
|
45
47
|
|
|
46
48
|
it('renders an array with index', async () => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
function App() {
|
|
50
|
+
return <>
|
|
51
|
+
const items = ['Item 1', 'Item 2', 'Item 3'];
|
|
52
|
+
for (const item of items; index i) {
|
|
53
|
+
<div class={`${item} ${i}`}>{`${item} ${i}`}</div>
|
|
54
|
+
}
|
|
55
|
+
</>;
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
const { body } = await render(App);
|
|
@@ -59,16 +62,17 @@ describe('for statements in SSR', () => {
|
|
|
59
62
|
});
|
|
60
63
|
|
|
61
64
|
it('renders an array with key', async () => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
function App() {
|
|
66
|
+
return <>
|
|
67
|
+
const items = [
|
|
68
|
+
{ id: 1, name: 'Item' },
|
|
69
|
+
{ id: 2, name: 'Item' },
|
|
70
|
+
{ id: 3, name: 'Item' },
|
|
71
|
+
];
|
|
72
|
+
for (const item of items; key item.id) {
|
|
73
|
+
<div class={`${item.name} ${item.id}`}>{`${item.name} ${item.id}`}</div>
|
|
74
|
+
}
|
|
75
|
+
</>;
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
const { body } = await render(App);
|
|
@@ -78,16 +82,17 @@ describe('for statements in SSR', () => {
|
|
|
78
82
|
});
|
|
79
83
|
|
|
80
84
|
it('renders an array with index and key', async () => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
function App() {
|
|
86
|
+
return <>
|
|
87
|
+
const items = [
|
|
88
|
+
{ id: 1, name: 'Item' },
|
|
89
|
+
{ id: 2, name: 'Item' },
|
|
90
|
+
{ id: 3, name: 'Item' },
|
|
91
|
+
];
|
|
92
|
+
for (const item of items; index i; key item.id) {
|
|
93
|
+
<div class={`${item.name} ${item.id} ${i}`}>{`${item.name} ${item.id} ${i}`}</div>
|
|
94
|
+
}
|
|
95
|
+
</>;
|
|
91
96
|
}
|
|
92
97
|
|
|
93
98
|
const { body } = await render(App);
|
|
@@ -97,13 +102,14 @@ describe('for statements in SSR', () => {
|
|
|
97
102
|
});
|
|
98
103
|
|
|
99
104
|
it('allows continue to skip a for...of iteration', async () => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
function App() {
|
|
106
|
+
return <>
|
|
107
|
+
const items = ['Item 1', '', 'Item 3'];
|
|
108
|
+
for (const item of items) {
|
|
109
|
+
if (!item) continue;
|
|
110
|
+
<div>{item}</div>
|
|
111
|
+
}
|
|
112
|
+
</>;
|
|
107
113
|
}
|
|
108
114
|
|
|
109
115
|
const { body } = await render(App);
|
|
@@ -111,22 +117,23 @@ describe('for statements in SSR', () => {
|
|
|
111
117
|
});
|
|
112
118
|
|
|
113
119
|
it('allows ordinary function control flow inside for...of loops', async () => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
function App() {
|
|
121
|
+
return <>
|
|
122
|
+
const items = ['Item 1', '', 'Item 3'];
|
|
123
|
+
for (const item of items) {
|
|
124
|
+
function label(value) {
|
|
125
|
+
for (let i = 0; i < 1; i++) {
|
|
126
|
+
while (i < 0) {
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
if (!value) return 'missing';
|
|
122
130
|
}
|
|
123
|
-
|
|
131
|
+
return value;
|
|
124
132
|
}
|
|
125
|
-
return value;
|
|
126
|
-
}
|
|
127
133
|
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
<div>{label(item)}</div>
|
|
135
|
+
}
|
|
136
|
+
</>;
|
|
130
137
|
}
|
|
131
138
|
|
|
132
139
|
const { body } = await render(App);
|
|
@@ -136,30 +143,30 @@ describe('for statements in SSR', () => {
|
|
|
136
143
|
it('throws for return statements inside for...of loops', () => {
|
|
137
144
|
expect(
|
|
138
145
|
() => compile(
|
|
139
|
-
`
|
|
146
|
+
`function App(items) { return <>
|
|
140
147
|
for (const item of items) {
|
|
141
148
|
if (!item) return
|
|
142
149
|
<div>{item}</div>
|
|
143
150
|
}
|
|
144
|
-
}`,
|
|
151
|
+
</>; }`,
|
|
145
152
|
'App.tsrx',
|
|
146
153
|
{ mode: 'server' },
|
|
147
154
|
),
|
|
148
|
-
).toThrow('Return statements are not allowed inside
|
|
155
|
+
).toThrow('Return statements are not allowed inside TSRX templates.');
|
|
149
156
|
});
|
|
150
157
|
|
|
151
158
|
it('throws for break statements targeting for...of loops', () => {
|
|
152
159
|
expect(
|
|
153
160
|
() => compile(
|
|
154
|
-
`
|
|
161
|
+
`function App(items) { return <>
|
|
155
162
|
for (const item of items) {
|
|
156
163
|
if (!item) break
|
|
157
164
|
<div>{item}</div>
|
|
158
165
|
}
|
|
159
|
-
}`,
|
|
166
|
+
</>; }`,
|
|
160
167
|
'App.tsrx',
|
|
161
168
|
{ mode: 'server' },
|
|
162
169
|
),
|
|
163
|
-
).toThrow('Break statements are not allowed inside
|
|
170
|
+
).toThrow('Break statements are not allowed inside TSRX template for...of loops');
|
|
164
171
|
});
|
|
165
172
|
});
|
|
@@ -2,12 +2,13 @@ import { track } from 'ripple';
|
|
|
2
2
|
|
|
3
3
|
describe('head elements', () => {
|
|
4
4
|
it('renders static title element', async () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
function App() {
|
|
6
|
+
return <>
|
|
7
|
+
<head>
|
|
8
|
+
<title>{'Static Test Title'}</title>
|
|
9
|
+
</head>
|
|
10
|
+
<div>{'Content'}</div>
|
|
11
|
+
</>;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const { head, body } = await render(App);
|
|
@@ -18,15 +19,16 @@ describe('head elements', () => {
|
|
|
18
19
|
});
|
|
19
20
|
|
|
20
21
|
it('renders reactive title element', async () => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
function App() {
|
|
23
|
+
return <>
|
|
24
|
+
let &[title] = track('Initial Title');
|
|
25
|
+
<head>
|
|
26
|
+
<title>{title}</title>
|
|
27
|
+
</head>
|
|
28
|
+
<div>
|
|
29
|
+
<span>{title}</span>
|
|
30
|
+
</div>
|
|
31
|
+
</>;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
const { head, body } = await render(App);
|
|
@@ -37,12 +39,13 @@ describe('head elements', () => {
|
|
|
37
39
|
});
|
|
38
40
|
|
|
39
41
|
it('renders title with template literal', async () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
function App() {
|
|
43
|
+
return <>
|
|
44
|
+
let &[name] = track('World');
|
|
45
|
+
<head>
|
|
46
|
+
<title>{`Hello ${name}!`}</title>
|
|
47
|
+
</head>
|
|
48
|
+
</>;
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
const { head, body } = await render(App);
|
|
@@ -52,16 +55,17 @@ describe('head elements', () => {
|
|
|
52
55
|
});
|
|
53
56
|
|
|
54
57
|
it('renders title with computed value', async () => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
function App() {
|
|
59
|
+
return <>
|
|
60
|
+
let &[count] = track(0);
|
|
61
|
+
let prefix = 'Count: ';
|
|
62
|
+
<head>
|
|
63
|
+
<title>{prefix + count}</title>
|
|
64
|
+
</head>
|
|
65
|
+
<div>
|
|
66
|
+
<span>{count}</span>
|
|
67
|
+
</div>
|
|
68
|
+
</>;
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
const { head, body } = await render(App);
|
|
@@ -71,11 +75,13 @@ describe('head elements', () => {
|
|
|
71
75
|
});
|
|
72
76
|
|
|
73
77
|
it('renders empty title', async () => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
function App() {
|
|
79
|
+
return <>
|
|
80
|
+
<head>
|
|
81
|
+
<title>{''}</title>
|
|
82
|
+
</head>
|
|
83
|
+
<div>{'Empty title test'}</div>
|
|
84
|
+
</>;
|
|
79
85
|
}
|
|
80
86
|
|
|
81
87
|
const { head, body } = await render(App);
|
|
@@ -85,13 +91,14 @@ describe('head elements', () => {
|
|
|
85
91
|
});
|
|
86
92
|
|
|
87
93
|
it('renders title with conditional content', async () => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
function App() {
|
|
95
|
+
return <>
|
|
96
|
+
let &[showPrefix] = track(true);
|
|
97
|
+
let &[title] = track('Main Page');
|
|
98
|
+
<head>
|
|
99
|
+
<title>{showPrefix ? 'App - ' + title : title}</title>
|
|
100
|
+
</head>
|
|
101
|
+
</>;
|
|
95
102
|
}
|
|
96
103
|
|
|
97
104
|
const { head, body } = await render(App);
|
|
@@ -180,11 +180,11 @@ describe('HTML nesting validation', () => {
|
|
|
180
180
|
describe('compiler dev mode output', () => {
|
|
181
181
|
it('emits push_element and pop_element calls in dev mode', () => {
|
|
182
182
|
const lines = [];
|
|
183
|
-
lines.push('
|
|
183
|
+
lines.push('function App() { return <>');
|
|
184
184
|
lines.push(' <div>');
|
|
185
185
|
lines.push(' <span>{"Hello"}</span>');
|
|
186
186
|
lines.push(' </div>');
|
|
187
|
-
lines.push('}');
|
|
187
|
+
lines.push('</>; }');
|
|
188
188
|
const source = lines.join('\n');
|
|
189
189
|
|
|
190
190
|
const result = compile(source, 'test.tsrx', { mode: 'server', dev: true });
|
|
@@ -195,11 +195,11 @@ describe('HTML nesting validation', () => {
|
|
|
195
195
|
|
|
196
196
|
it('does not emit push_element or pop_element in non-dev mode', () => {
|
|
197
197
|
const lines = [];
|
|
198
|
-
lines.push('
|
|
198
|
+
lines.push('function App() { return <>');
|
|
199
199
|
lines.push(' <div>');
|
|
200
200
|
lines.push(' <span>{"Hello"}</span>');
|
|
201
201
|
lines.push(' </div>');
|
|
202
|
-
lines.push('}');
|
|
202
|
+
lines.push('</>; }');
|
|
203
203
|
const source = lines.join('\n');
|
|
204
204
|
|
|
205
205
|
const result = compile(source, 'test.tsrx', { mode: 'server', dev: false });
|
|
@@ -210,9 +210,9 @@ describe('HTML nesting validation', () => {
|
|
|
210
210
|
|
|
211
211
|
it('emits push_element with correct tag name', () => {
|
|
212
212
|
const lines = [];
|
|
213
|
-
lines.push('
|
|
213
|
+
lines.push('function App() { return <>');
|
|
214
214
|
lines.push(' <button>{"Click"}</button>');
|
|
215
|
-
lines.push('}');
|
|
215
|
+
lines.push('</>; }');
|
|
216
216
|
const source = lines.join('\n');
|
|
217
217
|
|
|
218
218
|
const result = compile(source, 'test.tsrx', { mode: 'server', dev: true });
|
|
@@ -222,9 +222,9 @@ describe('HTML nesting validation', () => {
|
|
|
222
222
|
|
|
223
223
|
it('does not emit push_element for client mode', () => {
|
|
224
224
|
const lines = [];
|
|
225
|
-
lines.push('
|
|
225
|
+
lines.push('function App() { return <>');
|
|
226
226
|
lines.push(' <div>{"Hello"}</div>');
|
|
227
|
-
lines.push('}');
|
|
227
|
+
lines.push('</>; }');
|
|
228
228
|
const source = lines.join('\n');
|
|
229
229
|
|
|
230
230
|
const result = compile(source, 'test.tsrx', { mode: 'client', dev: true });
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
describe('if statements in SSR', () => {
|
|
2
2
|
it('renders if block when condition is true', async () => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
function App() {
|
|
4
|
+
return <>
|
|
5
|
+
let condition = true;
|
|
6
|
+
if (condition) {
|
|
7
|
+
<div>{'If block'}</div>
|
|
8
|
+
}
|
|
9
|
+
</>;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
const { body } = await render(App);
|
|
@@ -13,14 +14,15 @@ describe('if statements in SSR', () => {
|
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
it('renders else block when condition is false', async () => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
function App() {
|
|
18
|
+
return <>
|
|
19
|
+
let condition = false;
|
|
20
|
+
if (condition) {
|
|
21
|
+
<div>{'If block'}</div>
|
|
22
|
+
} else {
|
|
23
|
+
<div>{'Else block'}</div>
|
|
24
|
+
}
|
|
25
|
+
</>;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
const { body } = await render(App);
|
|
@@ -28,12 +30,13 @@ describe('if statements in SSR', () => {
|
|
|
28
30
|
});
|
|
29
31
|
|
|
30
32
|
it('renders bare double-quoted text in if-else branches', async () => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
function App() {
|
|
34
|
+
return <>
|
|
35
|
+
let condition = false;
|
|
36
|
+
if (condition) {
|
|
37
|
+
"Hello Ripple"
|
|
38
|
+
} else "Hello React"
|
|
39
|
+
</>;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
const { body } = await render(App);
|
|
@@ -41,16 +44,17 @@ describe('if statements in SSR', () => {
|
|
|
41
44
|
});
|
|
42
45
|
|
|
43
46
|
it('renders else if block when condition is true', async () => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
function App() {
|
|
48
|
+
return <>
|
|
49
|
+
let value = 'b';
|
|
50
|
+
if (value === 'a') {
|
|
51
|
+
<div>{'Case A'}</div>
|
|
52
|
+
} else if (value === 'b') {
|
|
53
|
+
<div>{'Case B'}</div>
|
|
54
|
+
} else {
|
|
55
|
+
<div>{'Default Case'}</div>
|
|
56
|
+
}
|
|
57
|
+
</>;
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
const { body } = await render(App);
|
|
@@ -58,16 +62,17 @@ describe('if statements in SSR', () => {
|
|
|
58
62
|
});
|
|
59
63
|
|
|
60
64
|
it('renders final else block in an if-else if-else chain', async () => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
function App() {
|
|
66
|
+
return <>
|
|
67
|
+
let value = 'c';
|
|
68
|
+
if (value === 'a') {
|
|
69
|
+
<div>{'Case A'}</div>
|
|
70
|
+
} else if (value === 'b') {
|
|
71
|
+
<div>{'Case B'}</div>
|
|
72
|
+
} else {
|
|
73
|
+
<div>{'Default Case'}</div>
|
|
74
|
+
}
|
|
75
|
+
</>;
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
const { body } = await render(App);
|
|
@@ -75,19 +80,20 @@ describe('if statements in SSR', () => {
|
|
|
75
80
|
});
|
|
76
81
|
|
|
77
82
|
it('renders nested if-else blocks correctly', async () => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
function App() {
|
|
84
|
+
return <>
|
|
85
|
+
let outer = true;
|
|
86
|
+
let inner = false;
|
|
87
|
+
if (outer) {
|
|
88
|
+
if (inner) {
|
|
89
|
+
<div>{'Outer true, Inner true'}</div>
|
|
90
|
+
} else {
|
|
91
|
+
<div>{'Outer true, Inner false'}</div>
|
|
92
|
+
}
|
|
85
93
|
} else {
|
|
86
|
-
<div>{'Outer
|
|
94
|
+
<div>{'Outer false'}</div>
|
|
87
95
|
}
|
|
88
|
-
|
|
89
|
-
<div>{'Outer false'}</div>
|
|
90
|
-
}
|
|
96
|
+
</>;
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
const { body } = await render(App);
|