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.
Files changed (182) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/package.json +3 -3
  3. package/src/jsx-runtime.d.ts +2 -2
  4. package/src/runtime/element.js +1 -1
  5. package/src/runtime/index-client.js +11 -11
  6. package/src/runtime/index-server.js +7 -4
  7. package/src/runtime/internal/client/bindings.js +1 -1
  8. package/src/runtime/internal/client/blocks.js +13 -4
  9. package/src/runtime/internal/client/component.js +55 -0
  10. package/src/runtime/internal/client/composite.js +4 -2
  11. package/src/runtime/internal/client/expression.js +65 -7
  12. package/src/runtime/internal/client/hmr.js +54 -43
  13. package/src/runtime/internal/client/index.js +5 -1
  14. package/src/runtime/internal/client/portal.js +70 -69
  15. package/src/runtime/internal/client/render.js +3 -0
  16. package/src/runtime/internal/server/index.js +92 -8
  17. package/tests/client/__snapshots__/html.test.tsrx.snap +3 -3
  18. package/tests/client/array/array.copy-within.test.tsrx +33 -31
  19. package/tests/client/array/array.derived.test.tsrx +186 -169
  20. package/tests/client/array/array.iteration.test.tsrx +40 -37
  21. package/tests/client/array/array.mutations.test.tsrx +113 -101
  22. package/tests/client/array/array.static.test.tsrx +119 -101
  23. package/tests/client/array/array.to-methods.test.tsrx +24 -21
  24. package/tests/client/async-suspend.test.tsrx +247 -246
  25. package/tests/client/basic/__snapshots__/basic.rendering.test.tsrx.snap +0 -1
  26. package/tests/client/basic/basic.attributes.test.tsrx +428 -423
  27. package/tests/client/basic/basic.collections.test.tsrx +109 -102
  28. package/tests/client/basic/basic.components.test.tsrx +323 -205
  29. package/tests/client/basic/basic.errors.test.tsrx +91 -91
  30. package/tests/client/basic/basic.events.test.tsrx +114 -115
  31. package/tests/client/basic/basic.get-set.test.tsrx +97 -87
  32. package/tests/client/basic/basic.hmr.test.tsrx +19 -16
  33. package/tests/client/basic/basic.reactivity.test.tsrx +199 -191
  34. package/tests/client/basic/basic.rendering.test.tsrx +272 -182
  35. package/tests/client/basic/basic.styling.test.tsrx +23 -22
  36. package/tests/client/basic/basic.utilities.test.tsrx +10 -8
  37. package/tests/client/boundaries.test.tsrx +26 -26
  38. package/tests/client/compiler/__snapshots__/compiler.assignments.test.rsrx.snap +5 -5
  39. package/tests/client/compiler/__snapshots__/compiler.assignments.test.tsrx.snap +5 -5
  40. package/tests/client/compiler/compiler.assignments.test.tsrx +77 -81
  41. package/tests/client/compiler/compiler.attributes.test.tsrx +15 -15
  42. package/tests/client/compiler/compiler.basic.test.tsrx +322 -314
  43. package/tests/client/compiler/compiler.regex.test.tsrx +44 -47
  44. package/tests/client/compiler/compiler.tracked-access.test.tsrx +38 -38
  45. package/tests/client/compiler/compiler.try-in-function.test.tsrx +16 -16
  46. package/tests/client/compiler/compiler.typescript.test.tsrx +2 -2
  47. package/tests/client/composite/composite.dynamic-components.test.tsrx +47 -48
  48. package/tests/client/composite/composite.generics.test.tsrx +168 -192
  49. package/tests/client/composite/composite.props.test.tsrx +97 -81
  50. package/tests/client/composite/composite.reactivity.test.tsrx +177 -147
  51. package/tests/client/composite/composite.render.test.tsrx +122 -105
  52. package/tests/client/computed-properties.test.tsrx +28 -28
  53. package/tests/client/context.test.tsrx +21 -21
  54. package/tests/client/css/global-additional-cases.test.tsrx +58 -58
  55. package/tests/client/css/global-advanced-selectors.test.tsrx +16 -16
  56. package/tests/client/css/global-at-rules.test.tsrx +10 -10
  57. package/tests/client/css/global-basic.test.tsrx +14 -14
  58. package/tests/client/css/global-classes-ids.test.tsrx +14 -14
  59. package/tests/client/css/global-combinators.test.tsrx +10 -10
  60. package/tests/client/css/global-complex-nesting.test.tsrx +14 -14
  61. package/tests/client/css/global-edge-cases.test.tsrx +18 -18
  62. package/tests/client/css/global-keyframes.test.tsrx +12 -12
  63. package/tests/client/css/global-nested.test.tsrx +10 -10
  64. package/tests/client/css/global-pseudo.test.tsrx +12 -12
  65. package/tests/client/css/global-scoping.test.tsrx +20 -20
  66. package/tests/client/css/style-identifier.test.tsrx +143 -291
  67. package/tests/client/date.test.tsrx +146 -133
  68. package/tests/client/dynamic-elements.test.tsrx +398 -365
  69. package/tests/client/events.test.tsrx +292 -290
  70. package/tests/client/for.test.tsrx +156 -153
  71. package/tests/client/head.test.tsrx +105 -96
  72. package/tests/client/html.test.tsrx +122 -26
  73. package/tests/client/input-value.test.tsrx +1361 -1314
  74. package/tests/client/lazy-array.test.tsrx +16 -13
  75. package/tests/client/lazy-destructuring.test.tsrx +257 -213
  76. package/tests/client/map.test.tsrx +65 -60
  77. package/tests/client/media-query.test.tsrx +22 -20
  78. package/tests/client/object.test.tsrx +87 -81
  79. package/tests/client/portal.test.tsrx +57 -51
  80. package/tests/client/ref.test.tsrx +233 -202
  81. package/tests/client/return.test.tsrx +71 -2560
  82. package/tests/client/set.test.tsrx +54 -45
  83. package/tests/client/svg.test.tsrx +216 -186
  84. package/tests/client/switch.test.tsrx +194 -193
  85. package/tests/client/track-async-hydration.test.tsrx +18 -14
  86. package/tests/client/tracked-index-access.test.tsrx +28 -18
  87. package/tests/client/try.test.tsrx +675 -548
  88. package/tests/client/tsx.test.tsrx +373 -311
  89. package/tests/client/typescript-generics.test.tsrx +145 -145
  90. package/tests/client/url/url.derived.test.tsrx +33 -28
  91. package/tests/client/url/url.parsing.test.tsrx +61 -51
  92. package/tests/client/url/url.partial-removal.test.tsrx +56 -48
  93. package/tests/client/url/url.reactivity.test.tsrx +142 -125
  94. package/tests/client/url/url.serialization.test.tsrx +13 -11
  95. package/tests/client/url-search-params/url-search-params.derived.test.tsrx +34 -29
  96. package/tests/client/url-search-params/url-search-params.initialization.test.tsrx +25 -21
  97. package/tests/client/url-search-params/url-search-params.iteration.test.tsrx +50 -45
  98. package/tests/client/url-search-params/url-search-params.mutation.test.tsrx +111 -99
  99. package/tests/client/url-search-params/url-search-params.retrieval.test.tsrx +49 -43
  100. package/tests/client/url-search-params/url-search-params.serialization.test.tsrx +14 -12
  101. package/tests/client/url-search-params/url-search-params.tracked-url.test.tsrx +16 -14
  102. package/tests/hydration/basic.test.js +3 -3
  103. package/tests/hydration/compiled/client/basic.js +586 -651
  104. package/tests/hydration/compiled/client/composite.js +79 -104
  105. package/tests/hydration/compiled/client/events.js +140 -148
  106. package/tests/hydration/compiled/client/for.js +1005 -1018
  107. package/tests/hydration/compiled/client/head.js +124 -134
  108. package/tests/hydration/compiled/client/hmr.js +41 -48
  109. package/tests/hydration/compiled/client/html-in-template.js +38 -41
  110. package/tests/hydration/compiled/client/html.js +970 -1314
  111. package/tests/hydration/compiled/client/if-children.js +234 -249
  112. package/tests/hydration/compiled/client/if.js +182 -189
  113. package/tests/hydration/compiled/client/mixed-control-flow.js +347 -303
  114. package/tests/hydration/compiled/client/nested-control-flow.js +1084 -832
  115. package/tests/hydration/compiled/client/portal.js +65 -85
  116. package/tests/hydration/compiled/client/reactivity.js +84 -90
  117. package/tests/hydration/compiled/client/return.js +38 -1939
  118. package/tests/hydration/compiled/client/switch.js +218 -224
  119. package/tests/hydration/compiled/client/track-async-serialization.js +250 -259
  120. package/tests/hydration/compiled/client/try.js +123 -132
  121. package/tests/hydration/compiled/server/basic.js +773 -831
  122. package/tests/hydration/compiled/server/composite.js +166 -191
  123. package/tests/hydration/compiled/server/events.js +170 -184
  124. package/tests/hydration/compiled/server/for.js +851 -909
  125. package/tests/hydration/compiled/server/head.js +206 -216
  126. package/tests/hydration/compiled/server/hmr.js +64 -72
  127. package/tests/hydration/compiled/server/html-in-template.js +42 -76
  128. package/tests/hydration/compiled/server/html.js +1362 -1667
  129. package/tests/hydration/compiled/server/if-children.js +419 -445
  130. package/tests/hydration/compiled/server/if.js +194 -208
  131. package/tests/hydration/compiled/server/mixed-control-flow.js +249 -257
  132. package/tests/hydration/compiled/server/nested-control-flow.js +491 -515
  133. package/tests/hydration/compiled/server/portal.js +152 -160
  134. package/tests/hydration/compiled/server/reactivity.js +94 -106
  135. package/tests/hydration/compiled/server/return.js +28 -2172
  136. package/tests/hydration/compiled/server/switch.js +274 -286
  137. package/tests/hydration/compiled/server/track-async-serialization.js +340 -358
  138. package/tests/hydration/compiled/server/try.js +167 -185
  139. package/tests/hydration/components/basic.tsrx +320 -272
  140. package/tests/hydration/components/composite.tsrx +44 -32
  141. package/tests/hydration/components/events.tsrx +101 -91
  142. package/tests/hydration/components/for.tsrx +510 -452
  143. package/tests/hydration/components/head.tsrx +87 -80
  144. package/tests/hydration/components/hmr.tsrx +22 -17
  145. package/tests/hydration/components/html-in-template.tsrx +22 -17
  146. package/tests/hydration/components/html.tsrx +525 -443
  147. package/tests/hydration/components/if-children.tsrx +158 -148
  148. package/tests/hydration/components/if.tsrx +109 -95
  149. package/tests/hydration/components/mixed-control-flow.tsrx +100 -96
  150. package/tests/hydration/components/nested-control-flow.tsrx +215 -203
  151. package/tests/hydration/components/portal.tsrx +41 -34
  152. package/tests/hydration/components/reactivity.tsrx +37 -27
  153. package/tests/hydration/components/return.tsrx +12 -556
  154. package/tests/hydration/components/switch.tsrx +120 -114
  155. package/tests/hydration/components/track-async-serialization.tsrx +107 -91
  156. package/tests/hydration/components/try.tsrx +55 -40
  157. package/tests/hydration/html.test.js +4 -4
  158. package/tests/hydration/return.test.js +13 -532
  159. package/tests/server/await.test.tsrx +3 -3
  160. package/tests/server/basic.attributes.test.tsrx +264 -195
  161. package/tests/server/basic.components.test.tsrx +296 -169
  162. package/tests/server/basic.test.tsrx +300 -198
  163. package/tests/server/compiler.test.tsrx +62 -60
  164. package/tests/server/composite.props.test.tsrx +77 -63
  165. package/tests/server/composite.test.tsrx +168 -192
  166. package/tests/server/context.test.tsrx +18 -12
  167. package/tests/server/dynamic-elements.test.tsrx +197 -180
  168. package/tests/server/for.test.tsrx +85 -78
  169. package/tests/server/head.test.tsrx +50 -43
  170. package/tests/server/html-nesting-validation.test.tsrx +8 -8
  171. package/tests/server/if.test.tsrx +57 -51
  172. package/tests/server/lazy-destructuring.test.tsrx +366 -294
  173. package/tests/server/return.test.tsrx +76 -1355
  174. package/tests/server/streaming-ssr.test.tsrx +4 -75
  175. package/tests/server/style-identifier.test.tsrx +169 -148
  176. package/tests/server/switch.test.tsrx +91 -85
  177. package/tests/server/track-async-serialization.test.tsrx +105 -85
  178. package/tests/server/try.test.tsrx +374 -280
  179. package/tests/utils/compiler-compat-config.test.js +2 -2
  180. package/tests/utils/runtime-imports.test.js +10 -0
  181. package/types/index.d.ts +8 -0
  182. package/tests/client/__snapshots__/html.test.rsrx.snap +0 -40
@@ -3,10 +3,11 @@ import { createRefKey, track } from 'ripple';
3
3
 
4
4
  describe('server dynamic DOM elements', () => {
5
5
  it('renders static dynamic element', async () => {
6
- component App() {
7
- let tag = track('div');
8
-
9
- <@tag>{'Hello World'}</@tag>
6
+ function App() {
7
+ return <>
8
+ let tag = track('div');
9
+ <@tag>{'Hello World'}</@tag>
10
+ </>;
10
11
  }
11
12
 
12
13
  const { body } = await render(App);
@@ -17,11 +18,12 @@ describe('server dynamic DOM elements', () => {
17
18
  // The ts errors below are due to limitations in our current tsx generation for dynamic elements.
18
19
  // They can be ignored for now. But we'll fix them via jsx() vs <jsx>
19
20
  it('renders static dynamic element from a plain object with a tracked property', async () => {
20
- component App() {
21
- let obj = { tag: track('div') };
22
- let tag = obj.tag;
23
-
24
- <@tag>{'Hello World'}</@tag>
21
+ function App() {
22
+ return <>
23
+ let obj = { tag: track('div') };
24
+ let tag = obj.tag;
25
+ <@tag>{'Hello World'}</@tag>
26
+ </>;
25
27
  }
26
28
 
27
29
  const { body } = await render(App);
@@ -30,11 +32,12 @@ describe('server dynamic DOM elements', () => {
30
32
  });
31
33
 
32
34
  it('renders static dynamic element from a tracked object with a tracked property', async () => {
33
- component App() {
34
- let obj = track({ tag: track('div') });
35
- let tag = obj.value.tag;
36
-
37
- <@tag>{'Hello World'}</@tag>
35
+ function App() {
36
+ return <>
37
+ let obj = track({ tag: track('div') });
38
+ let tag = obj.value.tag;
39
+ <@tag>{'Hello World'}</@tag>
40
+ </>;
38
41
  }
39
42
 
40
43
  const { body } = await render(App);
@@ -45,11 +48,12 @@ describe('server dynamic DOM elements', () => {
45
48
  it(
46
49
  'renders static dynamic element from a tracked object with a computed tracked property',
47
50
  async () => {
48
- component App() {
49
- let obj = track({ tag: track('div') });
50
- let tag = obj.value['tag'];
51
-
52
- <@tag>{'Hello World'}</@tag>
51
+ function App() {
52
+ return <>
53
+ let obj = track({ tag: track('div') });
54
+ let tag = obj.value['tag'];
55
+ <@tag>{'Hello World'}</@tag>
56
+ </>;
53
57
  }
54
58
 
55
59
  const { body } = await render(App);
@@ -59,10 +63,11 @@ describe('server dynamic DOM elements', () => {
59
63
  );
60
64
 
61
65
  it('renders self-closing dynamic element', async () => {
62
- component App() {
63
- let tag = track('input');
64
-
65
- <@tag type="text" value="test" />
66
+ function App() {
67
+ return <>
68
+ let tag = track('input');
69
+ <@tag type="text" value="test" />
70
+ </>;
66
71
  }
67
72
 
68
73
  const { body } = await render(App);
@@ -71,11 +76,12 @@ describe('server dynamic DOM elements', () => {
71
76
  });
72
77
 
73
78
  it('handles dynamic element with attributes', async () => {
74
- component App() {
75
- let tag = track('div');
76
- let &[className] = track('test-class');
77
-
78
- <@tag class={className} id="test" data-testid="dynamic-element">{'Content'}</@tag>
79
+ function App() {
80
+ return <>
81
+ let tag = track('div');
82
+ let &[className] = track('test-class');
83
+ <@tag class={className} id="test" data-testid="dynamic-element">{'Content'}</@tag>
84
+ </>;
79
85
  }
80
86
  const { body } = await render(App);
81
87
  const { document } = parseHtml(body);
@@ -89,13 +95,14 @@ describe('server dynamic DOM elements', () => {
89
95
  });
90
96
 
91
97
  it('handles nested dynamic elements', async () => {
92
- component App() {
93
- let outerTag = track('div');
94
- let innerTag = track('span');
95
-
96
- <@outerTag class="outer">
97
- <@innerTag class="inner">{'Nested content'}</@innerTag>
98
- </@outerTag>
98
+ function App() {
99
+ return <>
100
+ let outerTag = track('div');
101
+ let innerTag = track('span');
102
+ <@outerTag class="outer">
103
+ <@innerTag class="inner">{'Nested content'}</@innerTag>
104
+ </@outerTag>
105
+ </>;
99
106
  }
100
107
  const { body } = await render(App);
101
108
  const { document } = parseHtml(body);
@@ -110,11 +117,14 @@ describe('server dynamic DOM elements', () => {
110
117
  });
111
118
 
112
119
  it('handles dynamic element with class object', async () => {
113
- component App() {
114
- let tag = track('div');
115
- let &[active] = track(true);
116
-
117
- <@tag class={{ active: active, 'dynamic-element': true }}>{'Element with class object'}</@tag>
120
+ function App() {
121
+ return <>
122
+ let tag = track('div');
123
+ let &[active] = track(true);
124
+ <@tag class={{ active: active, 'dynamic-element': true }}>
125
+ {'Element with class object'}
126
+ </@tag>
127
+ </>;
118
128
  }
119
129
 
120
130
  const { body } = await render(App);
@@ -127,18 +137,19 @@ describe('server dynamic DOM elements', () => {
127
137
  });
128
138
 
129
139
  it('handles dynamic element with style object', async () => {
130
- component App() {
131
- let tag = track('span');
132
-
133
- <@tag
134
- style={{
135
- color: 'red',
136
- fontSize: '16px',
137
- fontWeight: 'bold',
138
- }}
139
- >
140
- {'Styled dynamic element'}
141
- </@tag>
140
+ function App() {
141
+ return <>
142
+ let tag = track('span');
143
+ <@tag
144
+ style={{
145
+ color: 'red',
146
+ fontSize: '16px',
147
+ fontWeight: 'bold',
148
+ }}
149
+ >
150
+ {'Styled dynamic element'}
151
+ </@tag>
152
+ </>;
142
153
  }
143
154
 
144
155
  const { body } = await render(App);
@@ -152,15 +163,16 @@ describe('server dynamic DOM elements', () => {
152
163
  });
153
164
 
154
165
  it('handles dynamic element with spread attributes', async () => {
155
- component App() {
156
- let tag = track('section');
157
- const attrs = {
158
- id: 'spread-section',
159
- 'data-testid': 'spread-test',
160
- class: 'spread-class',
161
- };
162
-
163
- <@tag {...attrs} data-extra="additional">{'Element with spread attributes'}</@tag>
166
+ function App() {
167
+ return <>
168
+ let tag = track('section');
169
+ const attrs = {
170
+ id: 'spread-section',
171
+ 'data-testid': 'spread-test',
172
+ class: 'spread-class',
173
+ };
174
+ <@tag {...attrs} data-extra="additional">{'Element with spread attributes'}</@tag>
175
+ </>;
164
176
  }
165
177
  const { body } = await render(App);
166
178
  const { document } = parseHtml(body);
@@ -176,17 +188,18 @@ describe('server dynamic DOM elements', () => {
176
188
  it('handles dynamic element with ref not rendered', async () => {
177
189
  let capturedElement: HTMLElement | null = null;
178
190
 
179
- component App() {
180
- let tag = track('article');
181
-
182
- <@tag
183
- {ref (node: HTMLElement) => {
184
- capturedElement = node;
185
- }}
186
- id="ref-test"
187
- >
188
- {'Element with ref'}
189
- </@tag>
191
+ function App() {
192
+ return <>
193
+ let tag = track('article');
194
+ <@tag
195
+ ref={(node: HTMLElement) => {
196
+ capturedElement = node;
197
+ }}
198
+ id="ref-test"
199
+ >
200
+ {'Element with ref'}
201
+ </@tag>
202
+ </>;
190
203
  }
191
204
 
192
205
  const { body } = await render(App);
@@ -202,22 +215,21 @@ describe('server dynamic DOM elements', () => {
202
215
  });
203
216
 
204
217
  it('handles dynamic element with createRefKey in spread', async () => {
205
- component App() {
206
- let tag = track('header');
207
-
208
- function elementRef(node: HTMLElement) {
209
- // Set an attribute on the element to prove ref was called
210
- node.setAttribute('data-spread-ref-called', 'true');
211
- node.setAttribute('data-spread-ref-tag', node.tagName.toLowerCase());
212
- }
213
-
214
- const dynamicProps = {
215
- id: 'spread-ref-test',
216
- class: 'ref-element',
217
- [createRefKey()]: elementRef,
218
- };
219
-
220
- <@tag {...dynamicProps}>{'Element with spread ref'}</@tag>
218
+ function App() {
219
+ return <>
220
+ let tag = track('header');
221
+ function elementRef(node: HTMLElement) {
222
+ // Set an attribute on the element to prove ref was called
223
+ node.setAttribute('data-spread-ref-called', 'true');
224
+ node.setAttribute('data-spread-ref-tag', node.tagName.toLowerCase());
225
+ }
226
+ const dynamicProps = {
227
+ id: 'spread-ref-test',
228
+ class: 'ref-element',
229
+ [createRefKey()]: elementRef,
230
+ };
231
+ <@tag {...dynamicProps}>{'Element with spread ref'}</@tag>
232
+ </>;
221
233
  }
222
234
 
223
235
  const { body } = await render(App);
@@ -233,16 +245,16 @@ describe('server dynamic DOM elements', () => {
233
245
  });
234
246
 
235
247
  it('applies scoped CSS to dynamic elements', async () => {
236
- component App() {
237
- let tag = track('div');
238
-
239
- <@tag class="test-class">{'Dynamic element'}</@tag>
240
-
241
- <style>
242
- .test-class {
243
- color: red;
244
- }
245
- </style>
248
+ function App() {
249
+ return <>
250
+ let tag = track('div');
251
+ <@tag class="test-class">{'Dynamic element'}</@tag>
252
+ <style>
253
+ .test-class {
254
+ color: red;
255
+ }
256
+ </style>
257
+ </>;
246
258
  }
247
259
 
248
260
  const { body } = await render(App);
@@ -258,26 +270,29 @@ describe('server dynamic DOM elements', () => {
258
270
  });
259
271
 
260
272
  it('handles spread attributes with class and CSS scoping', async () => {
261
- component DynamicButton(&{ ...rest }: PropsWithExtras<{
273
+ function DynamicButton(&{ ...rest }: PropsWithExtras<{
262
274
  class: string;
263
275
  id: string;
264
276
  }>) {
265
- const tag = track('button');
266
- <@tag {...rest}>{rest.class}</@tag>
267
-
268
- <style>
269
- .even {
270
- background-color: green;
271
- }
272
- .odd {
273
- background-color: red;
274
- }
275
- </style>
277
+ return <>
278
+ const tag = track('button');
279
+ <@tag {...rest}>{rest.class}</@tag>
280
+ <style>
281
+ .even {
282
+ background-color: green;
283
+ }
284
+ .odd {
285
+ background-color: red;
286
+ }
287
+ </style>
288
+ </>;
276
289
  }
277
290
 
278
- component App() {
279
- let &[count] = track(0);
280
- <DynamicButton class={count % 2 ? 'even' : 'odd'} id={count % 2 ? 'even' : 'odd'} />
291
+ function App() {
292
+ return <>
293
+ let &[count] = track(0);
294
+ <DynamicButton class={count % 2 ? 'even' : 'odd'} id={count % 2 ? 'even' : 'odd'} />
295
+ </>;
281
296
  }
282
297
 
283
298
  const { body } = await render(App);
@@ -297,18 +312,18 @@ describe('server dynamic DOM elements', () => {
297
312
  });
298
313
 
299
314
  it('adds scoping class to dynamic elements', async () => {
300
- component App() {
301
- let tag = track('div');
302
-
303
- <@tag class="scoped">
304
- <p>{'Scoped dynamic element'}</p>
305
- </@tag>
306
-
307
- <style>
308
- .scoped {
309
- color: blue;
310
- }
311
- </style>
315
+ function App() {
316
+ return <>
317
+ let tag = track('div');
318
+ <@tag class="scoped">
319
+ <p>{'Scoped dynamic element'}</p>
320
+ </@tag>
321
+ <style>
322
+ .scoped {
323
+ color: blue;
324
+ }
325
+ </style>
326
+ </>;
312
327
  }
313
328
 
314
329
  const { body } = await render(App);
@@ -326,18 +341,18 @@ describe('server dynamic DOM elements', () => {
326
341
  async () => {
327
342
  // NOTE: We always add the class scoping hash if there is css
328
343
  // but the tag selector will be marked as unused if it's not explicitly seen in the template.
329
- component App() {
330
- let tag = track('div');
331
-
332
- <@tag class="scoped">
333
- <p>{'Scoped dynamic element'}</p>
334
- </@tag>
335
-
336
- <style>
337
- div {
338
- color: blue;
339
- }
340
- </style>
344
+ function App() {
345
+ return <>
346
+ let tag = track('div');
347
+ <@tag class="scoped">
348
+ <p>{'Scoped dynamic element'}</p>
349
+ </@tag>
350
+ <style>
351
+ div {
352
+ color: blue;
353
+ }
354
+ </style>
355
+ </>;
341
356
  }
342
357
 
343
358
  const { body } = await render(App);
@@ -352,31 +367,32 @@ describe('server dynamic DOM elements', () => {
352
367
  );
353
368
 
354
369
  it('doesn\'t add scoping class to components inside dynamic element', async () => {
355
- component Child() {
356
- <div class="child">
357
- <p>{'I am a child component'}</p>
358
- </div>
359
-
360
- <style>
361
- .child {
362
- color: blue;
363
- }
364
- </style>
370
+ function Child() {
371
+ return <>
372
+ <div class="child">
373
+ <p>{'I am a child component'}</p>
374
+ </div>
375
+ <style>
376
+ .child {
377
+ color: blue;
378
+ }
379
+ </style>
380
+ </>;
365
381
  }
366
382
 
367
- component App() {
368
- let tag = track('div');
369
-
370
- <@tag class="scoped">
371
- <p>{'Scoped dynamic element'}</p>
372
- <Child />
373
- </@tag>
374
-
375
- <style>
376
- div {
377
- color: blue;
378
- }
379
- </style>
383
+ function App() {
384
+ return <>
385
+ let tag = track('div');
386
+ <@tag class="scoped">
387
+ <p>{'Scoped dynamic element'}</p>
388
+ <Child />
389
+ </@tag>
390
+ <style>
391
+ div {
392
+ color: blue;
393
+ }
394
+ </style>
395
+ </>;
380
396
  }
381
397
 
382
398
  const { body } = await render(App);
@@ -399,28 +415,29 @@ describe('server dynamic DOM elements', () => {
399
415
  });
400
416
 
401
417
  it('doesn\'t add scoping class to dynamically rendered component', async () => {
402
- component Child() {
403
- <div class="child">
404
- <p>{'I am a child component'}</p>
405
- </div>
406
-
407
- <style>
408
- .child {
409
- color: green;
410
- }
411
- </style>
418
+ function Child() {
419
+ return <>
420
+ <div class="child">
421
+ <p>{'I am a child component'}</p>
422
+ </div>
423
+ <style>
424
+ .child {
425
+ color: green;
426
+ }
427
+ </style>
428
+ </>;
412
429
  }
413
430
 
414
- component App() {
415
- let tag = track(() => Child);
416
-
417
- <@tag />
418
-
419
- <style>
420
- .child {
421
- color: red;
422
- }
423
- </style>
431
+ function App() {
432
+ return <>
433
+ let tag = track(() => Child);
434
+ <@tag />
435
+ <style>
436
+ .child {
437
+ color: red;
438
+ }
439
+ </style>
440
+ </>;
424
441
  }
425
442
 
426
443
  const { body } = await render(App);