ripple 0.3.72 → 0.3.76

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