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
|
@@ -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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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
|
-
|
|
273
|
+
function DynamicButton(&{ ...rest }: PropsWithExtras<{
|
|
262
274
|
class: string;
|
|
263
275
|
id: string;
|
|
264
276
|
}>) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
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
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
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
|
-
|
|
356
|
-
|
|
357
|
-
<
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
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
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
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
|
-
|
|
403
|
-
|
|
404
|
-
<
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
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
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
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);
|