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.
Files changed (165) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/package.json +3 -3
  3. package/src/jsx-runtime.d.ts +2 -8
  4. package/src/runtime/index-client.js +3 -13
  5. package/src/runtime/internal/client/blocks.js +3 -25
  6. package/src/runtime/internal/client/for.js +80 -5
  7. package/src/runtime/internal/client/index.js +0 -2
  8. package/src/runtime/internal/client/types.d.ts +0 -10
  9. package/tests/client/__snapshots__/computed-properties.test.tsrx.snap +8 -0
  10. package/tests/client/__snapshots__/for.test.tsrx.snap +22 -0
  11. package/tests/client/__snapshots__/html.test.tsrx.snap +4 -0
  12. package/tests/client/array/array.copy-within.test.tsrx +19 -19
  13. package/tests/client/array/array.derived.test.tsrx +97 -109
  14. package/tests/client/array/array.iteration.test.tsrx +28 -28
  15. package/tests/client/array/array.mutations.test.tsrx +68 -68
  16. package/tests/client/array/array.static.test.tsrx +82 -92
  17. package/tests/client/array/array.to-methods.test.tsrx +15 -15
  18. package/tests/client/async-suspend.test.tsrx +180 -179
  19. package/tests/client/basic/__snapshots__/basic.attributes.test.tsrx.snap +2 -0
  20. package/tests/client/basic/__snapshots__/basic.rendering.test.tsrx.snap +4 -0
  21. package/tests/client/basic/basic.attributes.test.tsrx +273 -317
  22. package/tests/client/basic/basic.collections.test.tsrx +59 -71
  23. package/tests/client/basic/basic.components.test.tsrx +196 -222
  24. package/tests/client/basic/basic.errors.test.tsrx +72 -78
  25. package/tests/client/basic/basic.events.test.tsrx +80 -85
  26. package/tests/client/basic/basic.get-set.test.tsrx +54 -64
  27. package/tests/client/basic/basic.hmr.test.tsrx +15 -19
  28. package/tests/client/basic/basic.reactivity.test.tsrx +121 -135
  29. package/tests/client/basic/basic.rendering.test.tsrx +273 -178
  30. package/tests/client/basic/basic.utilities.test.tsrx +8 -10
  31. package/tests/client/boundaries.test.tsrx +18 -18
  32. package/tests/client/compiler/compiler.assignments.test.tsrx +77 -76
  33. package/tests/client/compiler/compiler.attributes.test.tsrx +18 -14
  34. package/tests/client/compiler/compiler.basic.test.tsrx +364 -296
  35. package/tests/client/compiler/compiler.regex.test.tsrx +40 -44
  36. package/tests/client/compiler/compiler.tracked-access.test.tsrx +57 -38
  37. package/tests/client/compiler/compiler.try-in-function.test.tsrx +16 -16
  38. package/tests/client/compiler/compiler.typescript.test.tsrx +4 -3
  39. package/tests/client/composite/composite.dynamic-components.test.tsrx +41 -44
  40. package/tests/client/composite/composite.generics.test.tsrx +165 -167
  41. package/tests/client/composite/composite.props.test.tsrx +66 -74
  42. package/tests/client/composite/composite.reactivity.test.tsrx +132 -166
  43. package/tests/client/composite/composite.render.test.tsrx +92 -101
  44. package/tests/client/computed-properties.test.tsrx +14 -18
  45. package/tests/client/context.test.tsrx +14 -18
  46. package/tests/client/css/global-additional-cases.test.tsrx +491 -437
  47. package/tests/client/css/global-advanced-selectors.test.tsrx +169 -153
  48. package/tests/client/css/global-at-rules.test.tsrx +71 -66
  49. package/tests/client/css/global-basic.test.tsrx +105 -98
  50. package/tests/client/css/global-classes-ids.test.tsrx +128 -114
  51. package/tests/client/css/global-combinators.test.tsrx +83 -78
  52. package/tests/client/css/global-complex-nesting.test.tsrx +134 -120
  53. package/tests/client/css/global-edge-cases.test.tsrx +138 -120
  54. package/tests/client/css/global-keyframes.test.tsrx +108 -96
  55. package/tests/client/css/global-nested.test.tsrx +88 -78
  56. package/tests/client/css/global-pseudo.test.tsrx +104 -98
  57. package/tests/client/css/global-scoping.test.tsrx +145 -125
  58. package/tests/client/css/style-identifier.test.tsrx +62 -69
  59. package/tests/client/date.test.tsrx +83 -83
  60. package/tests/client/dynamic-elements.test.tsrx +227 -283
  61. package/tests/client/events.test.tsrx +252 -266
  62. package/tests/client/for.test.tsrx +120 -127
  63. package/tests/client/head.test.tsrx +40 -48
  64. package/tests/client/html.test.tsrx +37 -49
  65. package/tests/client/input-value.test.tsrx +1125 -1354
  66. package/tests/client/lazy-array.test.tsrx +10 -16
  67. package/tests/client/lazy-destructuring.test.tsrx +169 -221
  68. package/tests/client/map.test.tsrx +39 -41
  69. package/tests/client/media-query.test.tsrx +15 -19
  70. package/tests/client/object.test.tsrx +46 -56
  71. package/tests/client/portal.test.tsrx +31 -37
  72. package/tests/client/ref.test.tsrx +173 -193
  73. package/tests/client/return.test.tsrx +62 -37
  74. package/tests/client/set.test.tsrx +33 -33
  75. package/tests/client/svg.test.tsrx +195 -215
  76. package/tests/client/switch.test.tsrx +201 -191
  77. package/tests/client/track-async-hydration.test.tsrx +14 -18
  78. package/tests/client/tracked-index-access.test.tsrx +18 -28
  79. package/tests/client/try.test.tsrx +494 -619
  80. package/tests/client/tsx.test.tsrx +290 -371
  81. package/tests/client/typescript-generics.test.tsrx +121 -129
  82. package/tests/client/url/url.derived.test.tsrx +21 -25
  83. package/tests/client/url/url.parsing.test.tsrx +35 -35
  84. package/tests/client/url/url.partial-removal.test.tsrx +32 -32
  85. package/tests/client/url/url.reactivity.test.tsrx +68 -72
  86. package/tests/client/url/url.serialization.test.tsrx +8 -8
  87. package/tests/client/url-search-params/url-search-params.derived.test.tsrx +21 -27
  88. package/tests/client/url-search-params/url-search-params.initialization.test.tsrx +16 -16
  89. package/tests/client/url-search-params/url-search-params.iteration.test.tsrx +37 -37
  90. package/tests/client/url-search-params/url-search-params.mutation.test.tsrx +56 -60
  91. package/tests/client/url-search-params/url-search-params.retrieval.test.tsrx +32 -34
  92. package/tests/client/url-search-params/url-search-params.serialization.test.tsrx +9 -9
  93. package/tests/client/url-search-params/url-search-params.tracked-url.test.tsrx +10 -10
  94. package/tests/hydration/compiled/client/basic.js +396 -325
  95. package/tests/hydration/compiled/client/composite.js +52 -44
  96. package/tests/hydration/compiled/client/for.js +734 -604
  97. package/tests/hydration/compiled/client/head.js +183 -103
  98. package/tests/hydration/compiled/client/html.js +93 -86
  99. package/tests/hydration/compiled/client/if-children.js +95 -71
  100. package/tests/hydration/compiled/client/if.js +113 -89
  101. package/tests/hydration/compiled/client/mixed-control-flow.js +225 -209
  102. package/tests/hydration/compiled/client/nested-control-flow.js +94 -98
  103. package/tests/hydration/compiled/client/reactivity.js +26 -24
  104. package/tests/hydration/compiled/client/return.js +8 -42
  105. package/tests/hydration/compiled/client/switch.js +208 -173
  106. package/tests/hydration/compiled/client/track-async-serialization.js +176 -128
  107. package/tests/hydration/compiled/client/try.js +29 -21
  108. package/tests/hydration/compiled/server/basic.js +210 -221
  109. package/tests/hydration/compiled/server/composite.js +13 -14
  110. package/tests/hydration/compiled/server/for.js +427 -444
  111. package/tests/hydration/compiled/server/head.js +199 -189
  112. package/tests/hydration/compiled/server/html.js +33 -41
  113. package/tests/hydration/compiled/server/if-children.js +114 -117
  114. package/tests/hydration/compiled/server/if.js +77 -83
  115. package/tests/hydration/compiled/server/mixed-control-flow.js +145 -150
  116. package/tests/hydration/compiled/server/nested-control-flow.js +10 -0
  117. package/tests/hydration/compiled/server/reactivity.js +24 -22
  118. package/tests/hydration/compiled/server/return.js +6 -18
  119. package/tests/hydration/compiled/server/switch.js +179 -176
  120. package/tests/hydration/compiled/server/track-async-serialization.js +88 -70
  121. package/tests/hydration/compiled/server/try.js +31 -35
  122. package/tests/hydration/components/basic.tsrx +216 -286
  123. package/tests/hydration/components/composite.tsrx +32 -42
  124. package/tests/hydration/components/events.tsrx +81 -101
  125. package/tests/hydration/components/for.tsrx +270 -336
  126. package/tests/hydration/components/head.tsrx +43 -39
  127. package/tests/hydration/components/hmr.tsrx +16 -22
  128. package/tests/hydration/components/html-in-template.tsrx +15 -21
  129. package/tests/hydration/components/html.tsrx +442 -526
  130. package/tests/hydration/components/if-children.tsrx +107 -125
  131. package/tests/hydration/components/if.tsrx +68 -90
  132. package/tests/hydration/components/mixed-control-flow.tsrx +65 -72
  133. package/tests/hydration/components/nested-control-flow.tsrx +202 -216
  134. package/tests/hydration/components/portal.tsrx +33 -41
  135. package/tests/hydration/components/reactivity.tsrx +26 -34
  136. package/tests/hydration/components/return.tsrx +4 -6
  137. package/tests/hydration/components/switch.tsrx +73 -78
  138. package/tests/hydration/components/track-async-serialization.tsrx +83 -93
  139. package/tests/hydration/components/try.tsrx +37 -51
  140. package/tests/hydration/switch.test.js +8 -8
  141. package/tests/server/await.test.tsrx +3 -3
  142. package/tests/server/basic.attributes.test.tsrx +120 -167
  143. package/tests/server/basic.components.test.tsrx +163 -197
  144. package/tests/server/basic.test.tsrx +298 -220
  145. package/tests/server/compiler.test.tsrx +142 -72
  146. package/tests/server/composite.props.test.tsrx +54 -58
  147. package/tests/server/composite.test.tsrx +165 -167
  148. package/tests/server/context.test.tsrx +13 -17
  149. package/tests/server/dynamic-elements.test.tsrx +103 -135
  150. package/tests/server/for.test.tsrx +115 -84
  151. package/tests/server/head.test.tsrx +31 -31
  152. package/tests/server/html-nesting-validation.test.tsrx +16 -8
  153. package/tests/server/if.test.tsrx +49 -59
  154. package/tests/server/lazy-destructuring.test.tsrx +288 -366
  155. package/tests/server/return.test.tsrx +58 -36
  156. package/tests/server/streaming-ssr.test.tsrx +4 -4
  157. package/tests/server/style-identifier.test.tsrx +58 -66
  158. package/tests/server/switch.test.tsrx +89 -97
  159. package/tests/server/track-async-serialization.test.tsrx +85 -103
  160. package/tests/server/try.test.tsrx +275 -360
  161. package/tests/utils/ref-types.test.js +72 -0
  162. package/tests/utils/vite-plugin-config.test.js +41 -74
  163. package/types/index.d.ts +1 -0
  164. package/src/runtime/internal/client/compat.js +0 -40
  165. package/tests/utils/compiler-compat-config.test.js +0 -38
@@ -3,30 +3,23 @@ import { RippleObject, effect, flushSync, track } from 'ripple';
3
3
 
4
4
  describe('composite > reactivity', () => {
5
5
  it('renders composite components with object state', () => {
6
- function Button({ obj }: { obj: { count: Tracked<number> } }) {
7
- return <>
8
- <button
9
- class="count2"
10
- onClick={() => {
11
- obj.count.value++;
12
- }}
13
- >
14
- {obj.count.value}
15
- </button>
16
- </>;
6
+ function Button({ obj }: { obj: { count: Tracked<number> } }) @{
7
+ <button
8
+ class="count2"
9
+ onClick={() => {
10
+ obj.count.value++;
11
+ }}
12
+ >{obj.count.value}</button>
17
13
  }
18
14
 
19
- function App() {
20
- return <>
21
- <div>
22
- let obj = {
23
- count: track(0),
24
- };
25
-
26
- <span class="count">{obj.count.value}</span>
27
- <Button {obj} />
28
- </div>
29
- </>;
15
+ function App() @{
16
+ let obj = {
17
+ count: track(0),
18
+ };
19
+ <div>
20
+ <span class="count">{obj.count.value}</span>
21
+ <Button {obj} />
22
+ </div>
30
23
  }
31
24
 
32
25
  render(App);
@@ -41,41 +34,34 @@ describe('composite > reactivity', () => {
41
34
  });
42
35
 
43
36
  it('renders composite components with object state wrapped in an if statement', () => {
44
- function Button({ obj }: { obj: { count: Tracked<number> } }) {
45
- return <>
46
- <button
47
- class="count2"
48
- onClick={() => {
49
- obj.count.value++;
50
- }}
51
- >
52
- {obj.count.value}
53
- </button>
54
- </>;
37
+ function Button({ obj }: { obj: { count: Tracked<number> } }) @{
38
+ <button
39
+ class="count2"
40
+ onClick={() => {
41
+ obj.count.value++;
42
+ }}
43
+ >{obj.count.value}</button>
55
44
  }
56
45
 
57
- function OtherComponent({ obj }: { obj: { count: Tracked<number> } }) {
58
- return <><div class="count3">{obj.count.value}</div></>;
46
+ function OtherComponent({ obj }: { obj: { count: Tracked<number> } }) @{
47
+ <div class="count3">{obj.count.value}</div>
59
48
  }
60
49
 
61
- function App() {
62
- return <>
63
- <div>
64
- let obj = {
65
- count: track(0),
66
- };
67
-
68
- <span class="count">{obj.count.value}</span>
69
- <span>{' '}</span>
70
- if (obj) {
71
- <Button {obj} />
72
- }
73
-
74
- if (obj) {
75
- <OtherComponent {obj} />
76
- }
77
- </div>
78
- </>;
50
+ function App() @{
51
+ let obj = {
52
+ count: track(0),
53
+ };
54
+ <div>
55
+ <span class="count">{obj.count.value}</span>
56
+ <span>{' '}</span>
57
+ @if (obj) {
58
+ <Button {obj} />
59
+ }
60
+
61
+ @if (obj) {
62
+ <OtherComponent {obj} />
63
+ }
64
+ </div>
79
65
  }
80
66
 
81
67
  render(App);
@@ -91,34 +77,29 @@ describe('composite > reactivity', () => {
91
77
  });
92
78
 
93
79
  it('parents and children have isolated state', () => {
94
- function Button(props: { count: number }) {
95
- return <>
96
- let &[count] = track(() => props.count);
80
+ function Button(props: { count: number }) @{
81
+ let &[count] = track(() => props.count);
82
+ <button
83
+ onClick={() => {
84
+ count++;
85
+ }}
86
+ >
87
+ {'child: ' + count}
88
+ </button>
89
+ }
90
+
91
+ function App() @{
92
+ let &[count] = track(0);
93
+ <div>
97
94
  <button
98
95
  onClick={() => {
99
96
  count++;
100
97
  }}
101
98
  >
102
- {'child: ' + count}
99
+ {'parent: ' + count}
103
100
  </button>
104
- </>;
105
- }
106
-
107
- function App() {
108
- return <>
109
- <div>
110
- let &[count] = track(0);
111
-
112
- <button
113
- onClick={() => {
114
- count++;
115
- }}
116
- >
117
- {'parent: ' + count}
118
- </button>
119
- <Button {count} />
120
- </div>
121
- </>;
101
+ <Button {count} />
102
+ </div>
122
103
  }
123
104
 
124
105
  render(App);
@@ -142,34 +123,29 @@ describe('composite > reactivity', () => {
142
123
  });
143
124
 
144
125
  it('parents and children have isolated connected state (destructured props)', () => {
145
- function Button(&{ count }: { count: number }) {
146
- return <>
147
- let &[local_count] = track(() => count);
126
+ function Button(&{ count }: { count: number }) @{
127
+ let &[local_count] = track(() => count);
128
+ <button
129
+ onClick={() => {
130
+ local_count++;
131
+ }}
132
+ >
133
+ {'child: ' + local_count}
134
+ </button>
135
+ }
136
+
137
+ function App() @{
138
+ let &[count] = track(0);
139
+ <div>
148
140
  <button
149
141
  onClick={() => {
150
- local_count++;
142
+ count++;
151
143
  }}
152
144
  >
153
- {'child: ' + local_count}
145
+ {'parent: ' + count}
154
146
  </button>
155
- </>;
156
- }
157
-
158
- function App() {
159
- return <>
160
- <div>
161
- let &[count] = track(0);
162
-
163
- <button
164
- onClick={() => {
165
- count++;
166
- }}
167
- >
168
- {'parent: ' + count}
169
- </button>
170
- <Button {count} />
171
- </div>
172
- </>;
147
+ <Button {count} />
148
+ </div>
173
149
  }
174
150
 
175
151
  render(App);
@@ -195,18 +171,18 @@ describe('composite > reactivity', () => {
195
171
  it('handles spreading of props', () => {
196
172
  let logs: string[] = [];
197
173
 
198
- function App() {
199
- return <>
200
- let &[a] = track(1);
201
- let &[b] = track(2);
202
- let &[c] = track(3);
203
- let &[obj] = track(
204
- () => ({
205
- a,
206
- b,
207
- c,
208
- }),
209
- );
174
+ function App() @{
175
+ let &[a] = track(1);
176
+ let &[b] = track(2);
177
+ let &[c] = track(3);
178
+ let &[obj] = track(
179
+ () => ({
180
+ a,
181
+ b,
182
+ c,
183
+ }),
184
+ );
185
+ <>
210
186
  <Child {...obj} />
211
187
  <button
212
188
  onClick={() => {
@@ -214,19 +190,17 @@ describe('composite > reactivity', () => {
214
190
  b++;
215
191
  c++;
216
192
  }}
217
- >
218
- {'Increment all'}
219
- </button>
220
- </>;
193
+ >{'Increment all'}</button>
194
+ </>
221
195
  }
222
196
 
223
- function Child(&{ a, b, c }: { a: number; b: number; c: number }) {
224
- return <>
225
- effect(() => {
226
- logs.push(`Child effect: ${a}, ${b}, ${c}`);
227
- });
228
- <div>{a + ' ' + b + ' ' + c}</div>
229
- </>;
197
+ function Child(&{ a, b, c }: { a: number; b: number; c: number }) @{
198
+ effect(() => {
199
+ logs.push(`Child effect: ${a}, ${b}, ${c}`);
200
+ });
201
+ <div>
202
+ {a + ' ' + b + ' ' + c}
203
+ </div>
230
204
  }
231
205
 
232
206
  render(App);
@@ -244,27 +218,23 @@ describe('composite > reactivity', () => {
244
218
  });
245
219
 
246
220
  it('keeps reactivity for spread props via intermediate components and lazy destructuring', () => {
247
- function App() {
248
- return <>
249
- let &[count] = track(0);
250
- <CounterWrapper {count} up={() => count++} down={() => count--} />
251
- </>;
221
+ function App() @{
222
+ let &[count] = track(0);
223
+ <CounterWrapper {count} up={() => count++} down={() => count--} />
252
224
  }
253
225
 
254
- function CounterWrapper(props: Props) {
255
- return <>
256
- <div>
257
- <Counter {...props} />
258
- </div>
259
- </>;
226
+ function CounterWrapper(props: Props) @{
227
+ <div>
228
+ <Counter {...props} />
229
+ </div>
260
230
  }
261
231
 
262
- function Counter(&{ count, up, down, ...rest }: Props) {
263
- return <>
232
+ function Counter(&{ count, up, down, ...rest }: Props) @{
233
+ <>
264
234
  <button onClick={() => up()}>{'UP'}</button>
265
235
  <button onClick={() => down()}>{'DOWN'}</button>
266
236
  <span {...rest}>{`Counter: ${count}`}</span>
267
- </>;
237
+ </>
268
238
  }
269
239
 
270
240
  render(App);
@@ -287,36 +257,32 @@ describe('composite > reactivity', () => {
287
257
  });
288
258
 
289
259
  it('keeps reactivity on elements for element spreads and adds / removes dynamic props', () => {
290
- function App() {
291
- return <>
292
- let &[count] = track(0);
293
- <CounterWrapper {count} up={() => count++} />
294
- </>;
260
+ function App() @{
261
+ let &[count] = track(0);
262
+ <CounterWrapper {count} up={() => count++} />
295
263
  }
296
264
 
297
- function CounterWrapper(props: { count: number; up: () => void }) {
298
- return <>
299
- const more: {
300
- double: Tracked<number>;
301
- another?: number;
302
- extra: number;
303
- } = new RippleObject({
304
- double: track(() => props.count * 2),
305
- another: 0,
306
- extra: 100,
307
- });
308
- effect(() => {
309
- props.count;
310
- if (props.count === 1) {
311
- delete more.another;
312
- } else if (props.count === 2) {
313
- more.another = 0;
314
- }
315
- });
316
- <div>
317
- <Counter {...props} double={more.double} another={more.another} extra={more.extra} />
318
- </div>
319
- </>;
265
+ function CounterWrapper(props: { count: number; up: () => void }) @{
266
+ const more: {
267
+ double: Tracked<number>;
268
+ another?: number;
269
+ extra: number;
270
+ } = new RippleObject({
271
+ double: track(() => props.count * 2),
272
+ another: 0,
273
+ extra: 100,
274
+ });
275
+ effect(() => {
276
+ props.count;
277
+ if (props.count === 1) {
278
+ delete more.another;
279
+ } else if (props.count === 2) {
280
+ more.another = 0;
281
+ }
282
+ });
283
+ <div>
284
+ <Counter {...props} double={more.double} another={more.another} extra={more.extra} />
285
+ </div>
320
286
  }
321
287
 
322
288
  function Counter(&{
@@ -329,11 +295,11 @@ describe('composite > reactivity', () => {
329
295
  double: Tracked<number>;
330
296
  another?: number;
331
297
  extra: number;
332
- }) {
333
- return <>
298
+ }) @{
299
+ <>
334
300
  <div {...rest}>{`Counter: ${count} Double: ${rest.double.value}`}</div>
335
301
  <button onClick={() => up()}>{'UP'}</button>
336
- </>;
302
+ </>
337
303
  }
338
304
 
339
305
  render(App);
@@ -2,16 +2,16 @@ import { RippleArray, flushSync, track, type Component } from 'ripple';
2
2
 
3
3
  describe('composite > render', () => {
4
4
  it('renders composite components', () => {
5
- function Button(&{ count }: { count: number }) {
6
- return <><div>{count}</div></>;
5
+ function Button(&{ count }: { count: number }) @{
6
+ <div>{count}</div>
7
7
  }
8
8
 
9
- function App() {
10
- return <>
11
- let &[count] = track(0);
9
+ function App() @{
10
+ let &[count] = track(0);
11
+ <>
12
12
  <button onClick={() => count++}>{'Increment'}</button>
13
13
  <Button {count} />
14
- </>;
14
+ </>
15
15
  }
16
16
 
17
17
  render(App);
@@ -30,28 +30,26 @@ describe('composite > render', () => {
30
30
  });
31
31
 
32
32
  it('correct handles passing through component props and children', () => {
33
- function Button({ A, B, children }: { A: () => void; B: () => void; children: () => void }) {
34
- return <>
35
- <div>
36
- <A />
37
- {children}
38
- <B />
39
- </div>
40
- </>;
33
+ function Button({ A, B, children }: { A: () => void; B: () => void; children: () => void }) @{
34
+ <div>
35
+ <A />
36
+ {children}
37
+ <B />
38
+ </div>
41
39
  }
42
40
 
43
- function App() {
44
- return <>
45
- function A() {
46
- return <><div>{'I am A'}</div></>;
47
- }
48
- function B() {
49
- return <><div>{'I am B'}</div></>;
50
- }
51
- <Button {A} {B}>
52
- <div>{'other text'}</div>
53
- </Button>
54
- </>;
41
+ function A() @{
42
+ <div>{'I am A'}</div>
43
+ }
44
+
45
+ function B() @{
46
+ <div>{'I am B'}</div>
47
+ }
48
+
49
+ function App() @{
50
+ <Button {A} {B}>
51
+ <div>{'other text'}</div>
52
+ </Button>
55
53
  }
56
54
 
57
55
  render(App);
@@ -60,15 +58,13 @@ describe('composite > render', () => {
60
58
  });
61
59
 
62
60
  it('render simple text as children', () => {
63
- function App() {
64
- return <>
65
- let name = 'Click Me';
66
- <Child class="my-button">{name}</Child>
67
- </>;
61
+ function App() @{
62
+ let name = 'Click Me';
63
+ <Child class="my-button">{name}</Child>
68
64
  }
69
65
 
70
- function Child({ children, ...rest }: { children: string; class: string }) {
71
- return <><button {...rest}>{children}</button></>;
66
+ function Child({ children, ...rest }: { children: string; class: string }) @{
67
+ <button {...rest}>{children}</button>
72
68
  }
73
69
 
74
70
  render(App);
@@ -76,22 +72,18 @@ describe('composite > render', () => {
76
72
  });
77
73
 
78
74
  it('renders explicit text around children', () => {
79
- function Frame({ children }) {
80
- return <>
81
- <div class="frame">
82
- {'before'}
83
- {children}
84
- {'after'}
85
- </div>
86
- </>;
75
+ function Frame({ children }) @{
76
+ <div class="frame">
77
+ {'before'}
78
+ {children}
79
+ {'after'}
80
+ </div>
87
81
  }
88
82
 
89
- function App() {
90
- return <>
91
- <Frame>
92
- <span class="middle">{'middle'}</span>
93
- </Frame>
94
- </>;
83
+ function App() @{
84
+ <Frame>
85
+ <span class="middle">{'middle'}</span>
86
+ </Frame>
95
87
  }
96
88
 
97
89
  render(App);
@@ -112,35 +104,35 @@ describe('composite > render', () => {
112
104
  });
113
105
 
114
106
  it('preserves distinct scoped ripple hashes for wrapper and child content', () => {
115
- function App() {
116
- return <>
117
- function Wrapper({ children }) {
118
- return <>
119
- <div class="green">
120
- {'Wrapper'}
121
- {children}
122
- </div>
123
- <style>
124
- .green {
125
- color: green;
126
- }
127
- </style>
128
- </>;
129
- }
130
- function Child() {
131
- return <>
132
- <div class="red">{'Child'}</div>
133
- <style>
134
- .red {
135
- color: red;
136
- }
137
- </style>
138
- </>;
139
- }
140
- <Wrapper>
141
- <Child />
142
- </Wrapper>
143
- </>;
107
+ function Wrapper({ children }) @{
108
+ <>
109
+ <div class="green">
110
+ {'Wrapper'}
111
+ {children}
112
+ </div>
113
+ <style>
114
+ .green {
115
+ color: green;
116
+ }
117
+ </style>
118
+ </>
119
+ }
120
+
121
+ function Child() @{
122
+ <>
123
+ <div class="red">{'Child'}</div>
124
+ <style>
125
+ .red {
126
+ color: red;
127
+ }
128
+ </style>
129
+ </>
130
+ }
131
+
132
+ function App() @{
133
+ <Wrapper>
134
+ <Child />
135
+ </Wrapper>
144
136
  }
145
137
 
146
138
  render(App);
@@ -160,12 +152,12 @@ describe('composite > render', () => {
160
152
  });
161
153
 
162
154
  it('handles generics', () => {
163
- function ArrayTest() {
164
- return <>
165
- let items = new RippleArray<number>();
166
- items.push.apply(items, [1, 2, 3, 4, 5]);
167
- <pre>{items ? JSON.stringify(items) : 'Loading...'}</pre>
168
- </>;
155
+ function ArrayTest() @{
156
+ let items = new RippleArray<number>();
157
+ items.push.apply(items, [1, 2, 3, 4, 5]);
158
+ <pre>
159
+ {items ? JSON.stringify(items) : 'Loading...'}
160
+ </pre>
169
161
  }
170
162
 
171
163
  render(ArrayTest);
@@ -180,18 +172,17 @@ describe('composite > render', () => {
180
172
  children?: Component;
181
173
  NonExistent?: Component;
182
174
  [key: string]: any;
183
- }) {
184
- return <>
185
- <div {...props}>
186
- {children}
187
- // @ts-expect-error - intentionally testing behavior when a component is undefined
188
- <NonExistent />
189
- </div>
190
- </>;
175
+ }) @{
176
+ <div {...props}>
177
+ {children}
178
+
179
+ <NonExistent />
180
+ // @ts-expect-error - intentionally testing behavior when a component is undefined
181
+ </div>
191
182
  }
192
183
 
193
- function App() {
194
- return <><Child /></>;
184
+ function App() @{
185
+ <Child />
195
186
  }
196
187
 
197
188
  render(App);
@@ -206,8 +197,8 @@ describe('composite > render', () => {
206
197
 
207
198
  describe('scoped styles with children', () => {
208
199
  it('generates correct CSS hashes for wrapper and child with empty style in App', () => {
209
- function Wrapper(&{ children }: { children?: Component }) {
210
- return <>
200
+ function Wrapper(&{ children }: { children?: Component }) @{
201
+ <>
211
202
  <div class="green">
212
203
  {'Wrapper'}
213
204
  {children}
@@ -217,27 +208,27 @@ describe('scoped styles with children', () => {
217
208
  color: green;
218
209
  }
219
210
  </style>
220
- </>;
211
+ </>
221
212
  }
222
213
 
223
- function Child() {
224
- return <>
214
+ function Child() @{
215
+ <>
225
216
  <div class="red">{'Child'}</div>
226
217
  <style>
227
218
  .red {
228
219
  color: red;
229
220
  }
230
221
  </style>
231
- </>;
222
+ </>
232
223
  }
233
224
 
234
- function App() {
235
- return <>
225
+ function App() @{
226
+ <>
236
227
  <Wrapper>
237
228
  <Child />
238
229
  </Wrapper>
239
230
  <style></style>
240
- </>;
231
+ </>
241
232
  }
242
233
 
243
234
  render(App);