ripple 0.2.216 → 0.3.0
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 +39 -0
- package/package.json +16 -7
- package/src/compiler/errors.js +1 -1
- package/src/compiler/identifier-utils.js +2 -0
- package/src/compiler/index.d.ts +2 -6
- package/src/compiler/phases/1-parse/index.js +171 -233
- package/src/compiler/phases/2-analyze/index.js +192 -16
- package/src/compiler/phases/2-analyze/prune.js +2 -2
- package/src/compiler/phases/3-transform/client/index.js +308 -91
- package/src/compiler/phases/3-transform/segments.js +43 -15
- package/src/compiler/phases/3-transform/server/index.js +71 -21
- package/src/compiler/scope.js +31 -12
- package/src/compiler/source-map-utils.js +4 -6
- package/src/compiler/types/acorn.d.ts +11 -0
- package/src/compiler/types/estree-jsx.d.ts +11 -0
- package/src/compiler/types/estree.d.ts +11 -0
- package/src/compiler/types/import.d.ts +32 -18
- package/src/compiler/types/index.d.ts +75 -23
- package/src/compiler/types/parse.d.ts +7 -10
- package/src/compiler/utils.js +48 -0
- package/src/runtime/array.js +53 -22
- package/src/runtime/date.js +15 -5
- package/src/runtime/index-client.js +41 -7
- package/src/runtime/index-server.js +7 -7
- package/src/runtime/internal/client/bindings.js +2 -2
- package/src/runtime/internal/client/blocks.js +40 -1
- package/src/runtime/internal/client/context.js +8 -0
- package/src/runtime/internal/client/for.js +3 -3
- package/src/runtime/internal/client/index.js +32 -5
- package/src/runtime/internal/client/render.js +20 -8
- package/src/runtime/internal/client/runtime.js +9 -7
- package/src/runtime/internal/client/try.js +15 -22
- package/src/runtime/internal/client/utils.js +1 -1
- package/src/runtime/internal/server/context.js +8 -0
- package/src/runtime/internal/server/index.js +99 -6
- package/src/runtime/map.js +7 -7
- package/src/runtime/media-query.js +10 -1
- package/src/runtime/object.js +6 -6
- package/src/runtime/proxy.js +6 -6
- package/src/runtime/set.js +11 -11
- package/src/runtime/url-search-params.js +13 -2
- package/src/runtime/url.js +15 -5
- package/src/utils/builders.js +13 -3
- package/tests/client/array/array.copy-within.test.ripple +11 -11
- package/tests/client/array/array.derived.test.ripple +42 -42
- package/tests/client/array/array.iteration.test.ripple +12 -12
- package/tests/client/array/array.mutations.test.ripple +25 -25
- package/tests/client/array/array.static.test.ripple +103 -106
- package/tests/client/array/array.to-methods.test.ripple +8 -8
- package/tests/client/async-suspend.test.ripple +94 -0
- package/tests/client/basic/basic.attributes.test.ripple +31 -31
- package/tests/client/basic/basic.collections.test.ripple +7 -7
- package/tests/client/basic/basic.components.test.ripple +48 -10
- package/tests/client/basic/basic.errors.test.ripple +46 -31
- package/tests/client/basic/basic.events.test.ripple +11 -11
- package/tests/client/basic/basic.get-set.test.ripple +18 -18
- package/tests/client/basic/basic.reactivity.test.ripple +47 -42
- package/tests/client/basic/basic.rendering.test.ripple +7 -7
- package/tests/client/basic/basic.utilities.test.ripple +4 -4
- package/tests/client/boundaries.test.ripple +7 -7
- package/tests/client/compiler/__snapshots__/compiler.assignments.test.ripple.snap +2 -2
- package/tests/client/compiler/compiler.assignments.test.ripple +21 -21
- package/tests/client/compiler/compiler.basic.test.ripple +223 -82
- package/tests/client/compiler/compiler.tracked-access.test.ripple +8 -9
- package/tests/client/composite/composite.dynamic-components.test.ripple +8 -8
- package/tests/client/composite/composite.generics.test.ripple +4 -4
- package/tests/client/composite/composite.props.test.ripple +9 -9
- package/tests/client/composite/composite.reactivity.test.ripple +32 -26
- package/tests/client/composite/composite.render.test.ripple +13 -4
- package/tests/client/computed-properties.test.ripple +3 -3
- package/tests/client/context.test.ripple +3 -3
- package/tests/client/css/global-additional-cases.test.ripple +4 -4
- package/tests/client/css/style-identifier.test.ripple +49 -41
- package/tests/client/date.test.ripple +40 -40
- package/tests/client/dynamic-elements.test.ripple +165 -30
- package/tests/client/events.test.ripple +25 -25
- package/tests/client/for.test.ripple +76 -8
- package/tests/client/function-overload.test.ripple +0 -1
- package/tests/client/head.test.ripple +7 -7
- package/tests/client/html.test.ripple +2 -2
- package/tests/client/input-value.test.ripple +174 -176
- package/tests/client/map.test.ripple +21 -21
- package/tests/client/media-query.test.ripple +4 -4
- package/tests/client/object.test.ripple +12 -12
- package/tests/client/portal.test.ripple +4 -4
- package/tests/client/ref.test.ripple +5 -5
- package/tests/client/return.test.ripple +17 -17
- package/tests/client/set.test.ripple +16 -16
- package/tests/client/svg.test.ripple +6 -7
- package/tests/client/switch.test.ripple +10 -10
- package/tests/client/tracked-expression.test.ripple +1 -3
- package/tests/client/try.test.ripple +33 -4
- package/tests/client/url/url.derived.test.ripple +10 -9
- package/tests/client/url/url.parsing.test.ripple +10 -10
- package/tests/client/url/url.partial-removal.test.ripple +10 -10
- package/tests/client/url/url.reactivity.test.ripple +17 -17
- package/tests/client/url/url.serialization.test.ripple +4 -4
- package/tests/client/url-search-params/url-search-params.derived.test.ripple +11 -10
- package/tests/client/url-search-params/url-search-params.initialization.test.ripple +5 -7
- package/tests/client/url-search-params/url-search-params.iteration.test.ripple +13 -13
- package/tests/client/url-search-params/url-search-params.mutation.test.ripple +19 -19
- package/tests/client/url-search-params/url-search-params.retrieval.test.ripple +17 -17
- package/tests/client/url-search-params/url-search-params.serialization.test.ripple +5 -5
- package/tests/client/url-search-params/url-search-params.tracked-url.test.ripple +5 -5
- package/tests/hydration/compiled/client/events.js +8 -11
- package/tests/hydration/compiled/client/for.js +20 -23
- package/tests/hydration/compiled/client/head.js +17 -19
- package/tests/hydration/compiled/client/hmr.js +1 -3
- package/tests/hydration/compiled/client/html.js +1 -15
- package/tests/hydration/compiled/client/if-children.js +7 -9
- package/tests/hydration/compiled/client/if.js +5 -7
- package/tests/hydration/compiled/client/mixed-control-flow.js +3 -5
- package/tests/hydration/compiled/client/portal.js +1 -1
- package/tests/hydration/compiled/client/reactivity.js +9 -11
- package/tests/hydration/compiled/client/return.js +11 -13
- package/tests/hydration/compiled/client/switch.js +4 -6
- package/tests/hydration/compiled/server/basic.js +0 -1
- package/tests/hydration/compiled/server/composite.js +0 -3
- package/tests/hydration/compiled/server/events.js +8 -12
- package/tests/hydration/compiled/server/for.js +20 -23
- package/tests/hydration/compiled/server/head.js +17 -19
- package/tests/hydration/compiled/server/hmr.js +1 -4
- package/tests/hydration/compiled/server/html.js +1 -35
- package/tests/hydration/compiled/server/if-children.js +7 -11
- package/tests/hydration/compiled/server/if.js +5 -7
- package/tests/hydration/compiled/server/mixed-control-flow.js +3 -5
- package/tests/hydration/compiled/server/portal.js +1 -9
- package/tests/hydration/compiled/server/reactivity.js +9 -11
- package/tests/hydration/compiled/server/return.js +11 -13
- package/tests/hydration/compiled/server/switch.js +4 -6
- package/tests/hydration/components/events.ripple +8 -9
- package/tests/hydration/components/for.ripple +20 -21
- package/tests/hydration/components/head.ripple +6 -8
- package/tests/hydration/components/hmr.ripple +1 -2
- package/tests/hydration/components/html.ripple +1 -3
- package/tests/hydration/components/if-children.ripple +7 -8
- package/tests/hydration/components/if.ripple +5 -6
- package/tests/hydration/components/mixed-control-flow.ripple +4 -6
- package/tests/hydration/components/portal.ripple +1 -1
- package/tests/hydration/components/reactivity.ripple +9 -10
- package/tests/hydration/components/return.ripple +11 -12
- package/tests/hydration/components/switch.ripple +6 -8
- package/tests/server/await.test.ripple +2 -2
- package/tests/server/basic.attributes.test.ripple +19 -21
- package/tests/server/basic.components.test.ripple +13 -7
- package/tests/server/basic.test.ripple +20 -21
- package/tests/server/compiler.test.ripple +5 -5
- package/tests/server/composite.props.test.ripple +6 -7
- package/tests/server/composite.test.ripple +4 -4
- package/tests/server/context.test.ripple +1 -3
- package/tests/server/dynamic-elements.test.ripple +24 -24
- package/tests/server/head.test.ripple +5 -7
- package/tests/server/style-identifier.test.ripple +16 -17
- package/types/index.d.ts +266 -62
- package/types/server.d.ts +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RippleArray, RippleMap } from 'ripple';
|
|
2
2
|
|
|
3
3
|
describe('generics', () => {
|
|
4
4
|
it('handles advanced generic ambiguity and edge cases', () => {
|
|
@@ -143,10 +143,10 @@ describe('generics', () => {
|
|
|
143
143
|
const s = flag ? new Box<number>(1) : new Box<string>('string');
|
|
144
144
|
|
|
145
145
|
// 20. Generic inside template expression
|
|
146
|
-
const t = `length=${new
|
|
146
|
+
const t = `length=${new RippleArray<number>().length}`;
|
|
147
147
|
|
|
148
148
|
// 21. Optional chaining + generic + property access
|
|
149
|
-
const registry = new
|
|
149
|
+
const registry = new RippleMap<string, number>();
|
|
150
150
|
const u = registry.get('id')?.toString();
|
|
151
151
|
|
|
152
152
|
// 22. Generic call used as callee for another call
|
|
@@ -208,7 +208,7 @@ describe('generics', () => {
|
|
|
208
208
|
>();
|
|
209
209
|
|
|
210
210
|
// 33. Map of generic instance as key
|
|
211
|
-
const mm = new Map<
|
|
211
|
+
const mm = new Map<RippleArray<number>, RippleArray<string>>();
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
render(App);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { Context } from 'ripple';
|
|
2
|
-
|
|
3
1
|
describe('Context API', () => {
|
|
4
2
|
it('handles context override in nested components', async () => {
|
|
5
|
-
const MessageContext =
|
|
3
|
+
const MessageContext = #ripple.context('default');
|
|
6
4
|
|
|
7
5
|
component Inner() {
|
|
8
6
|
const msg = MessageContext.get();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { PropsWithExtras } from 'ripple';
|
|
2
|
-
import {
|
|
2
|
+
import { createRefKey } from 'ripple';
|
|
3
3
|
|
|
4
4
|
describe('server dynamic DOM elements', () => {
|
|
5
5
|
it('renders static dynamic element', async () => {
|
|
6
6
|
component App() {
|
|
7
|
-
let tag = track('div');
|
|
7
|
+
let tag = #ripple.track('div');
|
|
8
8
|
|
|
9
9
|
<@tag>{'Hello World'}</@tag>
|
|
10
10
|
}
|
|
@@ -18,7 +18,7 @@ describe('server dynamic DOM elements', () => {
|
|
|
18
18
|
// They can be ignored for now. But we'll fix them via jsx() vs <jsx>
|
|
19
19
|
it('renders static dynamic element from a plain object with a tracked property', async () => {
|
|
20
20
|
component App() {
|
|
21
|
-
let obj = { tag: track('div') };
|
|
21
|
+
let obj = { tag: #ripple.track('div') };
|
|
22
22
|
|
|
23
23
|
<obj.@tag>{'Hello World'}</obj.@tag>
|
|
24
24
|
}
|
|
@@ -30,7 +30,7 @@ describe('server dynamic DOM elements', () => {
|
|
|
30
30
|
|
|
31
31
|
it('renders static dynamic element from a tracked object with a tracked property', async () => {
|
|
32
32
|
component App() {
|
|
33
|
-
let obj = track({ tag: track('div') });
|
|
33
|
+
let obj = #ripple.track({ tag: #ripple.track('div') });
|
|
34
34
|
|
|
35
35
|
<@obj.@tag>{'Hello World'}</@obj.@tag>
|
|
36
36
|
}
|
|
@@ -44,7 +44,7 @@ describe('server dynamic DOM elements', () => {
|
|
|
44
44
|
'renders static dynamic element from a tracked object with a computed tracked property',
|
|
45
45
|
async () => {
|
|
46
46
|
component App() {
|
|
47
|
-
let obj = track({ tag: track('div') });
|
|
47
|
+
let obj = #ripple.track({ tag: #ripple.track('div') });
|
|
48
48
|
|
|
49
49
|
<@obj.@['tag']>{'Hello World'}</@obj.@['tag']>
|
|
50
50
|
}
|
|
@@ -57,7 +57,7 @@ describe('server dynamic DOM elements', () => {
|
|
|
57
57
|
|
|
58
58
|
it('renders self-closing dynamic element', async () => {
|
|
59
59
|
component App() {
|
|
60
|
-
let tag = track('input');
|
|
60
|
+
let tag = #ripple.track('input');
|
|
61
61
|
|
|
62
62
|
<@tag type="text" value="test" />
|
|
63
63
|
}
|
|
@@ -69,8 +69,8 @@ describe('server dynamic DOM elements', () => {
|
|
|
69
69
|
|
|
70
70
|
it('handles dynamic element with attributes', async () => {
|
|
71
71
|
component App() {
|
|
72
|
-
let tag = track('div');
|
|
73
|
-
let className = track('test-class');
|
|
72
|
+
let tag = #ripple.track('div');
|
|
73
|
+
let className = #ripple.track('test-class');
|
|
74
74
|
|
|
75
75
|
<@tag class={@className} id="test" data-testid="dynamic-element">{'Content'}</@tag>
|
|
76
76
|
}
|
|
@@ -87,8 +87,8 @@ describe('server dynamic DOM elements', () => {
|
|
|
87
87
|
|
|
88
88
|
it('handles nested dynamic elements', async () => {
|
|
89
89
|
component App() {
|
|
90
|
-
let outerTag = track('div');
|
|
91
|
-
let innerTag = track('span');
|
|
90
|
+
let outerTag = #ripple.track('div');
|
|
91
|
+
let innerTag = #ripple.track('span');
|
|
92
92
|
|
|
93
93
|
<@outerTag class="outer">
|
|
94
94
|
<@innerTag class="inner">{'Nested content'}</@innerTag>
|
|
@@ -108,8 +108,8 @@ describe('server dynamic DOM elements', () => {
|
|
|
108
108
|
|
|
109
109
|
it('handles dynamic element with class object', async () => {
|
|
110
110
|
component App() {
|
|
111
|
-
let tag = track('div');
|
|
112
|
-
let active = track(true);
|
|
111
|
+
let tag = #ripple.track('div');
|
|
112
|
+
let active = #ripple.track(true);
|
|
113
113
|
|
|
114
114
|
<@tag class={{ active: @active, 'dynamic-element': true }}>
|
|
115
115
|
{'Element with class object'}
|
|
@@ -127,7 +127,7 @@ describe('server dynamic DOM elements', () => {
|
|
|
127
127
|
|
|
128
128
|
it('handles dynamic element with style object', async () => {
|
|
129
129
|
component App() {
|
|
130
|
-
let tag = track('span');
|
|
130
|
+
let tag = #ripple.track('span');
|
|
131
131
|
|
|
132
132
|
<@tag
|
|
133
133
|
style={{
|
|
@@ -152,7 +152,7 @@ describe('server dynamic DOM elements', () => {
|
|
|
152
152
|
|
|
153
153
|
it('handles dynamic element with spread attributes', async () => {
|
|
154
154
|
component App() {
|
|
155
|
-
let tag = track('section');
|
|
155
|
+
let tag = #ripple.track('section');
|
|
156
156
|
const attrs = {
|
|
157
157
|
id: 'spread-section',
|
|
158
158
|
'data-testid': 'spread-test',
|
|
@@ -176,7 +176,7 @@ describe('server dynamic DOM elements', () => {
|
|
|
176
176
|
let capturedElement: HTMLElement | null = null;
|
|
177
177
|
|
|
178
178
|
component App() {
|
|
179
|
-
let tag = track('article');
|
|
179
|
+
let tag = #ripple.track('article');
|
|
180
180
|
|
|
181
181
|
<@tag
|
|
182
182
|
{ref (node: HTMLElement) => {
|
|
@@ -202,7 +202,7 @@ describe('server dynamic DOM elements', () => {
|
|
|
202
202
|
|
|
203
203
|
it('handles dynamic element with createRefKey in spread', async () => {
|
|
204
204
|
component App() {
|
|
205
|
-
let tag = track('header');
|
|
205
|
+
let tag = #ripple.track('header');
|
|
206
206
|
|
|
207
207
|
function elementRef(node: HTMLElement) {
|
|
208
208
|
// Set an attribute on the element to prove ref was called
|
|
@@ -233,7 +233,7 @@ describe('server dynamic DOM elements', () => {
|
|
|
233
233
|
|
|
234
234
|
it('applies scoped CSS to dynamic elements', async () => {
|
|
235
235
|
component App() {
|
|
236
|
-
let tag = track('div');
|
|
236
|
+
let tag = #ripple.track('div');
|
|
237
237
|
|
|
238
238
|
<@tag class="test-class">{'Dynamic element'}</@tag>
|
|
239
239
|
|
|
@@ -261,8 +261,8 @@ describe('server dynamic DOM elements', () => {
|
|
|
261
261
|
class: string;
|
|
262
262
|
id: string;
|
|
263
263
|
}>) {
|
|
264
|
-
const tag = track('button');
|
|
265
|
-
const [rest] = trackSplit(props, []);
|
|
264
|
+
const tag = #ripple.track('button');
|
|
265
|
+
const [rest] = #ripple.trackSplit(props, []);
|
|
266
266
|
<@tag {...@rest}>{@rest.class}</@tag>
|
|
267
267
|
|
|
268
268
|
<style>
|
|
@@ -276,7 +276,7 @@ describe('server dynamic DOM elements', () => {
|
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
component App() {
|
|
279
|
-
const count = track(0);
|
|
279
|
+
const count = #ripple.track(0);
|
|
280
280
|
<DynamicButton class={@count % 2 ? 'even' : 'odd'} id={@count % 2 ? 'even' : 'odd'} />
|
|
281
281
|
}
|
|
282
282
|
|
|
@@ -298,7 +298,7 @@ describe('server dynamic DOM elements', () => {
|
|
|
298
298
|
|
|
299
299
|
it('adds scoping class to dynamic elements', async () => {
|
|
300
300
|
component App() {
|
|
301
|
-
let tag = track('div');
|
|
301
|
+
let tag = #ripple.track('div');
|
|
302
302
|
|
|
303
303
|
<@tag class="scoped">
|
|
304
304
|
<p>{'Scoped dynamic element'}</p>
|
|
@@ -327,7 +327,7 @@ describe('server dynamic DOM elements', () => {
|
|
|
327
327
|
// NOTE: We always add the class scoping hash if there is css
|
|
328
328
|
// but the tag selector will be marked as unused if it's not explicitly seen in the template.
|
|
329
329
|
component App() {
|
|
330
|
-
let tag = track('div');
|
|
330
|
+
let tag = #ripple.track('div');
|
|
331
331
|
|
|
332
332
|
<@tag class="scoped">
|
|
333
333
|
<p>{'Scoped dynamic element'}</p>
|
|
@@ -365,7 +365,7 @@ describe('server dynamic DOM elements', () => {
|
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
component App() {
|
|
368
|
-
let tag = track('div');
|
|
368
|
+
let tag = #ripple.track('div');
|
|
369
369
|
|
|
370
370
|
<@tag class="scoped">
|
|
371
371
|
<p>{'Scoped dynamic element'}</p>
|
|
@@ -412,7 +412,7 @@ describe('server dynamic DOM elements', () => {
|
|
|
412
412
|
}
|
|
413
413
|
|
|
414
414
|
component App() {
|
|
415
|
-
let tag = track(() => Child);
|
|
415
|
+
let tag = #ripple.track(() => Child);
|
|
416
416
|
|
|
417
417
|
<@tag />
|
|
418
418
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { track } from 'ripple';
|
|
2
|
-
|
|
3
1
|
describe('head elements', () => {
|
|
4
2
|
it('renders static title element', async () => {
|
|
5
3
|
component App() {
|
|
@@ -19,7 +17,7 @@ describe('head elements', () => {
|
|
|
19
17
|
|
|
20
18
|
it('renders reactive title element', async () => {
|
|
21
19
|
component App() {
|
|
22
|
-
let title = track('Initial Title');
|
|
20
|
+
let title = #ripple.track('Initial Title');
|
|
23
21
|
|
|
24
22
|
<head>
|
|
25
23
|
<title>{@title}</title>
|
|
@@ -38,7 +36,7 @@ describe('head elements', () => {
|
|
|
38
36
|
|
|
39
37
|
it('renders title with template literal', async () => {
|
|
40
38
|
component App() {
|
|
41
|
-
let name = track('World');
|
|
39
|
+
let name = #ripple.track('World');
|
|
42
40
|
|
|
43
41
|
<head>
|
|
44
42
|
<title>{`Hello ${@name}!`}</title>
|
|
@@ -53,7 +51,7 @@ describe('head elements', () => {
|
|
|
53
51
|
|
|
54
52
|
it('renders title with computed value', async () => {
|
|
55
53
|
component App() {
|
|
56
|
-
let count = track(0);
|
|
54
|
+
let count = #ripple.track(0);
|
|
57
55
|
let prefix = 'Count: ';
|
|
58
56
|
|
|
59
57
|
<head>
|
|
@@ -86,8 +84,8 @@ describe('head elements', () => {
|
|
|
86
84
|
|
|
87
85
|
it('renders title with conditional content', async () => {
|
|
88
86
|
component App() {
|
|
89
|
-
let showPrefix = track(true);
|
|
90
|
-
let title = track('Main Page');
|
|
87
|
+
let showPrefix = #ripple.track(true);
|
|
88
|
+
let title = #ripple.track('Main Page');
|
|
91
89
|
|
|
92
90
|
<head>
|
|
93
91
|
<title>{@showPrefix ? 'App - ' + @title : @title}</title>
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { compile } from 'ripple/compiler';
|
|
2
|
-
import { track } from 'ripple';
|
|
3
2
|
|
|
4
|
-
describe('#style identifier (server)', () => {
|
|
3
|
+
describe('#ripple.style identifier (server)', () => {
|
|
5
4
|
describe('basic usage with components', () => {
|
|
6
|
-
it('passes scoped class to a child component via #style', async () => {
|
|
5
|
+
it('passes scoped class to a child component via #ripple.style', async () => {
|
|
7
6
|
component Child({ className }: { className: string }) {
|
|
8
7
|
<div class={className}>{'styled child'}</div>
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
component Parent() {
|
|
12
|
-
<Child className={#style.highlight} />
|
|
11
|
+
<Child className={#ripple.style.highlight} />
|
|
13
12
|
|
|
14
13
|
<style>
|
|
15
14
|
.highlight {
|
|
@@ -29,14 +28,14 @@ describe('#style identifier (server)', () => {
|
|
|
29
28
|
expect(classes.some((cls: string) => cls === 'highlight')).toBe(true);
|
|
30
29
|
});
|
|
31
30
|
|
|
32
|
-
it('passes multiple #style classes to a child component', async () => {
|
|
31
|
+
it('passes multiple #ripple.style classes to a child component', async () => {
|
|
33
32
|
component Child({ primary, secondary }: { primary: string; secondary: string }) {
|
|
34
33
|
<div class={primary}>{'primary'}</div>
|
|
35
34
|
<span class={secondary}>{'secondary'}</span>
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
component Parent() {
|
|
39
|
-
<Child primary={#style.primary} secondary={#style.secondary} />
|
|
38
|
+
<Child primary={#ripple.style.primary} secondary={#ripple.style.secondary} />
|
|
40
39
|
|
|
41
40
|
<style>
|
|
42
41
|
.primary {
|
|
@@ -68,13 +67,13 @@ describe('#style identifier (server)', () => {
|
|
|
68
67
|
});
|
|
69
68
|
|
|
70
69
|
describe('parent styling applied to child', () => {
|
|
71
|
-
it('allows parent to style child elements via #style prop', async () => {
|
|
70
|
+
it('allows parent to style child elements via #ripple.style prop', async () => {
|
|
72
71
|
component Button({ extraClass }: { extraClass?: string }) {
|
|
73
72
|
<button class={extraClass ?? ''}>{'Click me'}</button>
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
component App() {
|
|
77
|
-
<Button extraClass={#style.fancy} />
|
|
76
|
+
<Button extraClass={#ripple.style.fancy} />
|
|
78
77
|
|
|
79
78
|
<style>
|
|
80
79
|
.fancy {
|
|
@@ -93,7 +92,7 @@ describe('#style identifier (server)', () => {
|
|
|
93
92
|
expect(classes.some((cls: string) => cls === 'fancy')).toBe(true);
|
|
94
93
|
});
|
|
95
94
|
|
|
96
|
-
it('child can combine its own classes with parent #style class', async () => {
|
|
95
|
+
it('child can combine its own classes with parent #ripple.style class', async () => {
|
|
97
96
|
component Card({ className }: { className?: string }) {
|
|
98
97
|
<div class={['card-base', className ?? '']}>{'card content'}</div>
|
|
99
98
|
|
|
@@ -105,7 +104,7 @@ describe('#style identifier (server)', () => {
|
|
|
105
104
|
}
|
|
106
105
|
|
|
107
106
|
component App() {
|
|
108
|
-
<Card className={#style.themed} />
|
|
107
|
+
<Card className={#ripple.style.themed} />
|
|
109
108
|
|
|
110
109
|
<style>
|
|
111
110
|
.themed {
|
|
@@ -133,7 +132,7 @@ describe('#style identifier (server)', () => {
|
|
|
133
132
|
|
|
134
133
|
component App() {
|
|
135
134
|
<div class="parent">
|
|
136
|
-
<Child cls={#style.dual} />
|
|
135
|
+
<Child cls={#ripple.style.dual} />
|
|
137
136
|
</div>
|
|
138
137
|
|
|
139
138
|
<style>
|
|
@@ -158,15 +157,15 @@ describe('#style identifier (server)', () => {
|
|
|
158
157
|
);
|
|
159
158
|
});
|
|
160
159
|
|
|
161
|
-
it('passes scoped class to a dynamic child component via #style', async () => {
|
|
160
|
+
it('passes scoped class to a dynamic child component via #ripple.style', async () => {
|
|
162
161
|
component Child({ cls }: { cls: string }) {
|
|
163
162
|
<span class={cls}>{'text'}</span>
|
|
164
163
|
}
|
|
165
164
|
|
|
166
165
|
component Parent() {
|
|
167
|
-
let dynamic = track(() => Child);
|
|
166
|
+
let dynamic = #ripple.track(() => Child);
|
|
168
167
|
<div class="wrapper">
|
|
169
|
-
<@dynamic cls={#style.text} />
|
|
168
|
+
<@dynamic cls={#ripple.style.text} />
|
|
170
169
|
</div>
|
|
171
170
|
|
|
172
171
|
<style>
|
|
@@ -187,13 +186,13 @@ describe('#style identifier (server)', () => {
|
|
|
187
186
|
});
|
|
188
187
|
|
|
189
188
|
describe('server compiler output', () => {
|
|
190
|
-
it('generates #style object with standalone classes', () => {
|
|
189
|
+
it('generates #ripple.style object with standalone classes', () => {
|
|
191
190
|
const source = `
|
|
192
191
|
component Child({ cls }: { cls: string }) {
|
|
193
192
|
<div class={cls}>{'text'}</div>
|
|
194
193
|
}
|
|
195
194
|
export component App() {
|
|
196
|
-
<Child cls={#style.highlight} />
|
|
195
|
+
<Child cls={#ripple.style.highlight} />
|
|
197
196
|
|
|
198
197
|
<style>
|
|
199
198
|
.highlight {
|
|
@@ -214,7 +213,7 @@ export component App() {
|
|
|
214
213
|
}
|
|
215
214
|
|
|
216
215
|
component App() {
|
|
217
|
-
<Child cls={#style.styled} />
|
|
216
|
+
<Child cls={#ripple.style.styled} />
|
|
218
217
|
|
|
219
218
|
<style>
|
|
220
219
|
.styled {
|