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.
- package/CHANGELOG.md +116 -0
- package/package.json +3 -3
- package/src/jsx-runtime.d.ts +4 -10
- package/src/runtime/dynamic-client.js +33 -0
- package/src/runtime/dynamic-server.js +80 -0
- package/src/runtime/index-client.js +5 -13
- package/src/runtime/index-server.js +2 -0
- package/src/runtime/internal/client/blocks.js +6 -27
- package/src/runtime/internal/client/composite.js +11 -6
- package/src/runtime/internal/client/for.js +80 -5
- package/src/runtime/internal/client/index.js +0 -2
- package/src/runtime/internal/client/render.js +5 -2
- package/src/runtime/internal/client/types.d.ts +0 -10
- package/src/runtime/internal/server/index.js +8 -1
- package/tests/client/__snapshots__/computed-properties.test.tsrx.snap +8 -0
- package/tests/client/__snapshots__/for.test.tsrx.snap +22 -0
- package/tests/client/__snapshots__/html.test.tsrx.snap +4 -0
- package/tests/client/array/array.copy-within.test.tsrx +19 -19
- package/tests/client/array/array.derived.test.tsrx +97 -109
- package/tests/client/array/array.iteration.test.tsrx +28 -28
- package/tests/client/array/array.mutations.test.tsrx +68 -68
- package/tests/client/array/array.static.test.tsrx +82 -92
- package/tests/client/array/array.to-methods.test.tsrx +15 -15
- package/tests/client/async-suspend.test.tsrx +180 -179
- package/tests/client/basic/__snapshots__/basic.attributes.test.tsrx.snap +2 -0
- package/tests/client/basic/__snapshots__/basic.rendering.test.tsrx.snap +4 -0
- package/tests/client/basic/basic.attributes.test.tsrx +273 -317
- package/tests/client/basic/basic.collections.test.tsrx +55 -61
- package/tests/client/basic/basic.components.test.tsrx +198 -220
- package/tests/client/basic/basic.errors.test.tsrx +70 -76
- package/tests/client/basic/basic.events.test.tsrx +80 -85
- package/tests/client/basic/basic.get-set.test.tsrx +54 -64
- package/tests/client/basic/basic.hmr.test.tsrx +15 -19
- package/tests/client/basic/basic.reactivity.test.tsrx +121 -135
- package/tests/client/basic/basic.rendering.test.tsrx +273 -178
- package/tests/client/basic/basic.styling.test.tsrx +16 -14
- package/tests/client/basic/basic.utilities.test.tsrx +8 -10
- package/tests/client/boundaries.test.tsrx +18 -18
- package/tests/client/compiler/compiler.assignments.test.tsrx +77 -76
- package/tests/client/compiler/compiler.attributes.test.tsrx +18 -14
- package/tests/client/compiler/compiler.basic.test.tsrx +357 -288
- package/tests/client/compiler/compiler.regex.test.tsrx +40 -44
- package/tests/client/compiler/compiler.tracked-access.test.tsrx +57 -38
- package/tests/client/compiler/compiler.try-in-function.test.tsrx +16 -16
- package/tests/client/compiler/compiler.typescript.test.tsrx +4 -3
- package/tests/client/composite/composite.dynamic-components.test.tsrx +62 -47
- package/tests/client/composite/composite.generics.test.tsrx +165 -167
- package/tests/client/composite/composite.props.test.tsrx +66 -74
- package/tests/client/composite/composite.reactivity.test.tsrx +132 -166
- package/tests/client/composite/composite.render.test.tsrx +92 -101
- package/tests/client/computed-properties.test.tsrx +14 -18
- package/tests/client/context.test.tsrx +14 -18
- package/tests/client/css/global-additional-cases.test.tsrx +493 -439
- package/tests/client/css/global-advanced-selectors.test.tsrx +169 -153
- package/tests/client/css/global-at-rules.test.tsrx +71 -66
- package/tests/client/css/global-basic.test.tsrx +105 -98
- package/tests/client/css/global-classes-ids.test.tsrx +128 -114
- package/tests/client/css/global-combinators.test.tsrx +83 -78
- package/tests/client/css/global-complex-nesting.test.tsrx +134 -120
- package/tests/client/css/global-edge-cases.test.tsrx +138 -120
- package/tests/client/css/global-keyframes.test.tsrx +108 -96
- package/tests/client/css/global-nested.test.tsrx +88 -78
- package/tests/client/css/global-pseudo.test.tsrx +104 -98
- package/tests/client/css/global-scoping.test.tsrx +145 -125
- package/tests/client/css/style-identifier.test.tsrx +65 -72
- package/tests/client/date.test.tsrx +83 -83
- package/tests/client/dynamic-elements.test.tsrx +318 -299
- package/tests/client/events.test.tsrx +252 -266
- package/tests/client/for.test.tsrx +120 -127
- package/tests/client/head.test.tsrx +74 -48
- package/tests/client/html.test.tsrx +37 -49
- package/tests/client/input-value.test.tsrx +1125 -1354
- package/tests/client/lazy-array.test.tsrx +10 -16
- package/tests/client/lazy-destructuring.test.tsrx +169 -221
- package/tests/client/map.test.tsrx +39 -41
- package/tests/client/media-query.test.tsrx +15 -19
- package/tests/client/object.test.tsrx +46 -56
- package/tests/client/portal.test.tsrx +31 -37
- package/tests/client/ref.test.tsrx +173 -193
- package/tests/client/return.test.tsrx +62 -37
- package/tests/client/set.test.tsrx +33 -33
- package/tests/client/svg.test.tsrx +197 -216
- package/tests/client/switch.test.tsrx +201 -191
- package/tests/client/track-async-hydration.test.tsrx +14 -18
- package/tests/client/tracked-index-access.test.tsrx +18 -28
- package/tests/client/try.test.tsrx +494 -619
- package/tests/client/tsx.test.tsrx +286 -292
- package/tests/client/typescript-generics.test.tsrx +121 -129
- package/tests/client/url/url.derived.test.tsrx +21 -25
- package/tests/client/url/url.parsing.test.tsrx +35 -35
- package/tests/client/url/url.partial-removal.test.tsrx +32 -32
- package/tests/client/url/url.reactivity.test.tsrx +68 -72
- package/tests/client/url/url.serialization.test.tsrx +8 -8
- package/tests/client/url-search-params/url-search-params.derived.test.tsrx +21 -27
- package/tests/client/url-search-params/url-search-params.initialization.test.tsrx +16 -16
- package/tests/client/url-search-params/url-search-params.iteration.test.tsrx +37 -37
- package/tests/client/url-search-params/url-search-params.mutation.test.tsrx +56 -60
- package/tests/client/url-search-params/url-search-params.retrieval.test.tsrx +32 -34
- package/tests/client/url-search-params/url-search-params.serialization.test.tsrx +9 -9
- package/tests/client/url-search-params/url-search-params.tracked-url.test.tsrx +10 -10
- package/tests/hydration/compiled/client/basic.js +390 -319
- package/tests/hydration/compiled/client/composite.js +52 -44
- package/tests/hydration/compiled/client/for.js +734 -604
- package/tests/hydration/compiled/client/head.js +183 -103
- package/tests/hydration/compiled/client/html.js +93 -86
- package/tests/hydration/compiled/client/if-children.js +95 -71
- package/tests/hydration/compiled/client/if.js +113 -89
- package/tests/hydration/compiled/client/mixed-control-flow.js +225 -209
- package/tests/hydration/compiled/client/nested-control-flow.js +94 -98
- package/tests/hydration/compiled/client/reactivity.js +26 -24
- package/tests/hydration/compiled/client/return.js +8 -42
- package/tests/hydration/compiled/client/switch.js +208 -173
- package/tests/hydration/compiled/client/track-async-serialization.js +176 -128
- package/tests/hydration/compiled/client/try.js +29 -21
- package/tests/hydration/compiled/server/basic.js +210 -221
- package/tests/hydration/compiled/server/composite.js +13 -14
- package/tests/hydration/compiled/server/for.js +427 -444
- package/tests/hydration/compiled/server/head.js +199 -189
- package/tests/hydration/compiled/server/html.js +33 -41
- package/tests/hydration/compiled/server/if-children.js +114 -117
- package/tests/hydration/compiled/server/if.js +77 -83
- package/tests/hydration/compiled/server/mixed-control-flow.js +145 -150
- package/tests/hydration/compiled/server/nested-control-flow.js +10 -0
- package/tests/hydration/compiled/server/reactivity.js +24 -22
- package/tests/hydration/compiled/server/return.js +6 -18
- package/tests/hydration/compiled/server/switch.js +179 -176
- package/tests/hydration/compiled/server/track-async-serialization.js +88 -70
- package/tests/hydration/compiled/server/try.js +31 -35
- package/tests/hydration/components/basic.tsrx +216 -258
- package/tests/hydration/components/composite.tsrx +32 -42
- package/tests/hydration/components/events.tsrx +81 -101
- package/tests/hydration/components/for.tsrx +270 -336
- package/tests/hydration/components/head.tsrx +43 -39
- package/tests/hydration/components/hmr.tsrx +16 -22
- package/tests/hydration/components/html-in-template.tsrx +15 -21
- package/tests/hydration/components/html.tsrx +442 -526
- package/tests/hydration/components/if-children.tsrx +107 -125
- package/tests/hydration/components/if.tsrx +68 -90
- package/tests/hydration/components/mixed-control-flow.tsrx +65 -72
- package/tests/hydration/components/nested-control-flow.tsrx +202 -216
- package/tests/hydration/components/portal.tsrx +33 -41
- package/tests/hydration/components/reactivity.tsrx +26 -34
- package/tests/hydration/components/return.tsrx +4 -6
- package/tests/hydration/components/switch.tsrx +73 -78
- package/tests/hydration/components/track-async-serialization.tsrx +83 -93
- package/tests/hydration/components/try.tsrx +37 -51
- package/tests/hydration/switch.test.js +8 -8
- package/tests/server/await.test.tsrx +3 -3
- package/tests/server/basic.attributes.test.tsrx +117 -162
- package/tests/server/basic.components.test.tsrx +164 -194
- package/tests/server/basic.test.tsrx +299 -199
- package/tests/server/compiler.test.tsrx +142 -72
- package/tests/server/composite.props.test.tsrx +54 -58
- package/tests/server/composite.test.tsrx +165 -167
- package/tests/server/context.test.tsrx +13 -17
- package/tests/server/dynamic-elements.test.tsrx +147 -148
- package/tests/server/for.test.tsrx +115 -84
- package/tests/server/head.test.tsrx +54 -31
- package/tests/server/html-nesting-validation.test.tsrx +16 -8
- package/tests/server/if.test.tsrx +49 -59
- package/tests/server/lazy-destructuring.test.tsrx +288 -366
- package/tests/server/return.test.tsrx +58 -36
- package/tests/server/streaming-ssr.test.tsrx +4 -4
- package/tests/server/style-identifier.test.tsrx +61 -69
- package/tests/server/switch.test.tsrx +89 -97
- package/tests/server/track-async-serialization.test.tsrx +85 -103
- package/tests/server/try.test.tsrx +275 -360
- package/tests/utils/ref-types.test.js +72 -0
- package/tests/utils/vite-plugin-config.test.js +41 -74
- package/types/index.d.ts +29 -4
- package/src/runtime/internal/client/compat.js +0 -40
- package/tests/utils/compiler-compat-config.test.js +0 -38
|
@@ -4,15 +4,17 @@ import { compile } from '@tsrx/ripple';
|
|
|
4
4
|
describe('CSS :global additional use cases', () => {
|
|
5
5
|
it('handles :global as modifier with dot notation', () => {
|
|
6
6
|
const source = `
|
|
7
|
-
export function Test() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
export function Test() @{
|
|
8
|
+
<>
|
|
9
|
+
<div class="x">{'content'}</div>
|
|
10
|
+
|
|
11
|
+
<style>
|
|
12
|
+
div :global.x {
|
|
13
|
+
color: red;
|
|
14
|
+
}
|
|
15
|
+
</style>
|
|
16
|
+
</>
|
|
17
|
+
}`;
|
|
16
18
|
const { css } = compile(source, 'test.tsrx');
|
|
17
19
|
|
|
18
20
|
expect(css).toMatch(/div\.tsrx-[a-z0-9]+\.x {/);
|
|
@@ -20,17 +22,19 @@ export function Test() { return <>
|
|
|
20
22
|
|
|
21
23
|
it('handles :global modifier in nested syntax', () => {
|
|
22
24
|
const source = `
|
|
23
|
-
export function Test() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
export function Test() @{
|
|
26
|
+
<>
|
|
27
|
+
<div class="x">{'content'}</div>
|
|
28
|
+
|
|
29
|
+
<style>
|
|
30
|
+
div {
|
|
31
|
+
:global.x {
|
|
32
|
+
color: green;
|
|
33
|
+
}
|
|
30
34
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
</style>
|
|
36
|
+
</>
|
|
37
|
+
}`;
|
|
34
38
|
const { css } = compile(source, 'test.tsrx');
|
|
35
39
|
|
|
36
40
|
expect(css).toContain('&.x {');
|
|
@@ -38,17 +42,19 @@ export function Test() { return <>
|
|
|
38
42
|
|
|
39
43
|
it('handles :global with & nesting selector inside block', () => {
|
|
40
44
|
const source = `
|
|
41
|
-
export function Test() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
export function Test() @{
|
|
46
|
+
<>
|
|
47
|
+
<div class="x">{'content'}</div>
|
|
48
|
+
|
|
49
|
+
<style>
|
|
50
|
+
div {
|
|
51
|
+
& :global.x {
|
|
52
|
+
color: green;
|
|
53
|
+
}
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
</style>
|
|
56
|
+
</>
|
|
57
|
+
}`;
|
|
52
58
|
const { css } = compile(source, 'test.tsrx');
|
|
53
59
|
|
|
54
60
|
expect(css).toContain('&.x {');
|
|
@@ -56,15 +62,17 @@ export function Test() { return <>
|
|
|
56
62
|
|
|
57
63
|
it('handles :global with :is pseudo-class modifier', () => {
|
|
58
64
|
const source = `
|
|
59
|
-
export function Test() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
export function Test() @{
|
|
66
|
+
<>
|
|
67
|
+
<div>{'content'}</div>
|
|
68
|
+
|
|
69
|
+
<style>
|
|
70
|
+
div :global:is(html.dark-mode *) {
|
|
71
|
+
color: green;
|
|
72
|
+
}
|
|
73
|
+
</style>
|
|
74
|
+
</>
|
|
75
|
+
}`;
|
|
68
76
|
const { css } = compile(source, 'test.tsrx');
|
|
69
77
|
|
|
70
78
|
expect(css).toMatch(/div\.tsrx-[a-z0-9]+:is\(html\.dark-mode \*\) {/);
|
|
@@ -72,17 +80,19 @@ export function Test() { return <>
|
|
|
72
80
|
|
|
73
81
|
it('handles :global with & inside :global block', () => {
|
|
74
82
|
const source = `
|
|
75
|
-
export function Test() {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
export function Test() @{
|
|
84
|
+
<>
|
|
85
|
+
<div class="class">{'content'}</div>
|
|
86
|
+
|
|
87
|
+
<style>
|
|
88
|
+
div {
|
|
89
|
+
&:global(.class) {
|
|
90
|
+
color: green;
|
|
91
|
+
}
|
|
82
92
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
93
|
+
</style>
|
|
94
|
+
</>
|
|
95
|
+
}`;
|
|
86
96
|
const { css } = compile(source, 'test.tsrx');
|
|
87
97
|
|
|
88
98
|
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ {/);
|
|
@@ -91,17 +101,19 @@ export function Test() { return <>
|
|
|
91
101
|
|
|
92
102
|
it('handles :global(*) with & and descendant', () => {
|
|
93
103
|
const source = `
|
|
94
|
-
export function Test() {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
104
|
+
export function Test() @{
|
|
105
|
+
<>
|
|
106
|
+
<div class="class">{'content'}</div>
|
|
107
|
+
|
|
108
|
+
<style>
|
|
109
|
+
:global(*) {
|
|
110
|
+
&:hover .class {
|
|
111
|
+
color: green;
|
|
112
|
+
}
|
|
101
113
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
114
|
+
</style>
|
|
115
|
+
</>
|
|
116
|
+
}`;
|
|
105
117
|
const { css } = compile(source, 'test.tsrx');
|
|
106
118
|
|
|
107
119
|
expect(css).toContain('* {');
|
|
@@ -110,16 +122,18 @@ export function Test() { return <>
|
|
|
110
122
|
|
|
111
123
|
it('handles multiple :global selectors in list', () => {
|
|
112
124
|
const source = `
|
|
113
|
-
export function Test() {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
125
|
+
export function Test() @{
|
|
126
|
+
<>
|
|
127
|
+
<x>{'content'}</x>
|
|
128
|
+
<y>{'content'}</y>
|
|
129
|
+
|
|
130
|
+
<style>
|
|
131
|
+
:global x, :global y {
|
|
132
|
+
color: green;
|
|
133
|
+
}
|
|
134
|
+
</style>
|
|
135
|
+
</>
|
|
136
|
+
}`;
|
|
123
137
|
const { css } = compile(source, 'test.tsrx');
|
|
124
138
|
|
|
125
139
|
expect(css).toContain(' x, y {');
|
|
@@ -127,19 +141,21 @@ export function Test() { return <>
|
|
|
127
141
|
|
|
128
142
|
it('handles :global block with nested selector list', () => {
|
|
129
143
|
const source = `
|
|
130
|
-
export function Test() {
|
|
131
|
-
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
144
|
+
export function Test() @{
|
|
145
|
+
<>
|
|
146
|
+
<div>
|
|
147
|
+
<y>{'content'}</y>
|
|
148
|
+
</div>
|
|
149
|
+
|
|
150
|
+
<style>
|
|
151
|
+
div :global, div :global y, unused :global {
|
|
152
|
+
z {
|
|
153
|
+
color: green;
|
|
154
|
+
}
|
|
139
155
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
156
|
+
</style>
|
|
157
|
+
</>
|
|
158
|
+
}`;
|
|
143
159
|
const { css } = compile(source, 'test.tsrx');
|
|
144
160
|
|
|
145
161
|
expect(css).toMatch(/div\.tsrx-[a-z0-9]+/);
|
|
@@ -148,33 +164,35 @@ export function Test() { return <>
|
|
|
148
164
|
|
|
149
165
|
it('handles keyframes inside :global block', () => {
|
|
150
166
|
const source = `
|
|
151
|
-
export function Test() {
|
|
152
|
-
|
|
167
|
+
export function Test() @{
|
|
168
|
+
<>
|
|
169
|
+
<div class="x">{'animated'}</div>
|
|
170
|
+
|
|
171
|
+
<style>
|
|
172
|
+
:global {
|
|
173
|
+
.x {
|
|
174
|
+
animation: test 1s;
|
|
175
|
+
}
|
|
153
176
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
animation: test 1s;
|
|
158
|
-
}
|
|
177
|
+
.y {
|
|
178
|
+
animation: test-in 1s;
|
|
179
|
+
}
|
|
159
180
|
|
|
160
|
-
|
|
161
|
-
|
|
181
|
+
@keyframes test-in {
|
|
182
|
+
to {
|
|
183
|
+
opacity: 1;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
162
186
|
}
|
|
163
187
|
|
|
164
|
-
@keyframes test
|
|
188
|
+
@keyframes test {
|
|
165
189
|
to {
|
|
166
190
|
opacity: 1;
|
|
167
191
|
}
|
|
168
192
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
to {
|
|
173
|
-
opacity: 1;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
</style>
|
|
177
|
-
</>; }`;
|
|
193
|
+
</style>
|
|
194
|
+
</>
|
|
195
|
+
}`;
|
|
178
196
|
const { css } = compile(source, 'test.tsrx');
|
|
179
197
|
|
|
180
198
|
expect(css).toContain('@keyframes test-in {');
|
|
@@ -186,16 +204,18 @@ export function Test() { return <>
|
|
|
186
204
|
|
|
187
205
|
it('handles global keyframes with no component elements', () => {
|
|
188
206
|
const source = `
|
|
189
|
-
export function Test() {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
207
|
+
export function Test() @{
|
|
208
|
+
<>
|
|
209
|
+
<div>{'content'}</div>
|
|
210
|
+
|
|
211
|
+
<style>
|
|
212
|
+
@keyframes -global-orphan {
|
|
213
|
+
0% { color: red; }
|
|
214
|
+
100% { color: blue; }
|
|
215
|
+
}
|
|
216
|
+
</style>
|
|
217
|
+
</>
|
|
218
|
+
}`;
|
|
199
219
|
const { css } = compile(source, 'test.tsrx');
|
|
200
220
|
|
|
201
221
|
expect(css).toContain('@keyframes orphan');
|
|
@@ -204,22 +224,24 @@ export function Test() { return <>
|
|
|
204
224
|
|
|
205
225
|
it('handles :global with class modifier syntax', () => {
|
|
206
226
|
const source = `
|
|
207
|
-
export function Test() {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
227
|
+
export function Test() @{
|
|
228
|
+
<>
|
|
229
|
+
<div class="blue">{'might be programmatically added'}</div>
|
|
230
|
+
<span class="x blue">{'span content'}</span>
|
|
231
|
+
|
|
232
|
+
<style>
|
|
233
|
+
div:global(.blue) {
|
|
234
|
+
color: blue;
|
|
235
|
+
}
|
|
236
|
+
span:global(.blue).x {
|
|
237
|
+
color: blue;
|
|
238
|
+
}
|
|
239
|
+
span.x:global(.bg) {
|
|
240
|
+
background: red;
|
|
241
|
+
}
|
|
242
|
+
</style>
|
|
243
|
+
</>
|
|
244
|
+
}`;
|
|
223
245
|
const { css } = compile(source, 'test.tsrx');
|
|
224
246
|
|
|
225
247
|
expect(css).toMatch(/div\.tsrx-[a-z0-9]+\.blue {/);
|
|
@@ -229,15 +251,17 @@ export function Test() { return <>
|
|
|
229
251
|
|
|
230
252
|
it('handles multiple :global() in descendant sequence', () => {
|
|
231
253
|
const source = `
|
|
232
|
-
export function Test() {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
254
|
+
export function Test() @{
|
|
255
|
+
<>
|
|
256
|
+
<p>{'this may or may not be styled'}</p>
|
|
257
|
+
|
|
258
|
+
<style>
|
|
259
|
+
:global(div) > :global(section) > p {
|
|
260
|
+
color: red;
|
|
261
|
+
}
|
|
262
|
+
</style>
|
|
263
|
+
</>
|
|
264
|
+
}`;
|
|
241
265
|
const { css } = compile(source, 'test.tsrx');
|
|
242
266
|
|
|
243
267
|
expect(css).toContain('div > section > p');
|
|
@@ -246,19 +270,21 @@ export function Test() { return <>
|
|
|
246
270
|
|
|
247
271
|
it('handles :is with :global and html context', () => {
|
|
248
272
|
const source = `
|
|
249
|
-
export function Test() {
|
|
250
|
-
|
|
251
|
-
<
|
|
252
|
-
<
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
273
|
+
export function Test() @{
|
|
274
|
+
<>
|
|
275
|
+
<x>
|
|
276
|
+
<y>
|
|
277
|
+
<z>{'content'}</z>
|
|
278
|
+
</y>
|
|
279
|
+
</x>
|
|
280
|
+
|
|
281
|
+
<style>
|
|
282
|
+
x :is(:global(html *)) {
|
|
283
|
+
color: green;
|
|
284
|
+
}
|
|
285
|
+
</style>
|
|
286
|
+
</>
|
|
287
|
+
}`;
|
|
262
288
|
const { css } = compile(source, 'test.tsrx');
|
|
263
289
|
|
|
264
290
|
expect(css).toMatch(/x\.tsrx-[a-z0-9]+ :is\(html \*\) {/);
|
|
@@ -266,26 +292,28 @@ export function Test() { return <>
|
|
|
266
292
|
|
|
267
293
|
it('handles :global block with :has inside', () => {
|
|
268
294
|
const source = `
|
|
269
|
-
export function Test() {
|
|
270
|
-
|
|
271
|
-
<
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
:
|
|
277
|
-
|
|
295
|
+
export function Test() @{
|
|
296
|
+
<>
|
|
297
|
+
<div>
|
|
298
|
+
<x>{'content'}</x>
|
|
299
|
+
</div>
|
|
300
|
+
|
|
301
|
+
<style>
|
|
302
|
+
:global(.foo) {
|
|
303
|
+
:has(x) {
|
|
304
|
+
color: green;
|
|
305
|
+
}
|
|
306
|
+
&:has(x) {
|
|
307
|
+
color: green;
|
|
308
|
+
}
|
|
278
309
|
}
|
|
279
|
-
|
|
310
|
+
|
|
311
|
+
:global(.foo):has(x) {
|
|
280
312
|
color: green;
|
|
281
313
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
color: green;
|
|
286
|
-
}
|
|
287
|
-
</style>
|
|
288
|
-
</>; }`;
|
|
314
|
+
</style>
|
|
315
|
+
</>
|
|
316
|
+
}`;
|
|
289
317
|
const { css } = compile(source, 'test.tsrx');
|
|
290
318
|
|
|
291
319
|
expect(css).toContain('.foo {');
|
|
@@ -296,51 +324,53 @@ export function Test() { return <>
|
|
|
296
324
|
|
|
297
325
|
it('handles :not with :global in complex nesting', () => {
|
|
298
326
|
const source = `
|
|
299
|
-
export function Test() {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
:not(.foo):not(:global(.unused)) {
|
|
312
|
-
color: green;
|
|
313
|
-
}
|
|
314
|
-
:global(.x):not(.foo) {
|
|
315
|
-
color: green;
|
|
316
|
-
}
|
|
317
|
-
:global(.x) :not(p) {
|
|
318
|
-
color: green;
|
|
319
|
-
}
|
|
320
|
-
:global(.x):not(p) {
|
|
321
|
-
color: green;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
:global(span):not(p span) {
|
|
325
|
-
color: green;
|
|
326
|
-
}
|
|
327
|
-
span:not(:global(p span)) {
|
|
328
|
-
color: green;
|
|
329
|
-
}
|
|
330
|
-
:global(span:not(p span)) {
|
|
331
|
-
color: green;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
:global(.x) {
|
|
335
|
-
:not(.foo) {
|
|
327
|
+
export function Test() @{
|
|
328
|
+
<>
|
|
329
|
+
<p class="foo">{'foo'}</p>
|
|
330
|
+
<p class="bar">
|
|
331
|
+
{'bar'}
|
|
332
|
+
<span>{'baz'}</span>
|
|
333
|
+
</p>
|
|
334
|
+
<span>{'buzz'}</span>
|
|
335
|
+
|
|
336
|
+
<style>
|
|
337
|
+
:not(:global(.foo)) {
|
|
336
338
|
color: green;
|
|
337
339
|
}
|
|
338
|
-
|
|
340
|
+
:not(.foo):not(:global(.unused)) {
|
|
339
341
|
color: green;
|
|
340
342
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
343
|
+
:global(.x):not(.foo) {
|
|
344
|
+
color: green;
|
|
345
|
+
}
|
|
346
|
+
:global(.x) :not(p) {
|
|
347
|
+
color: green;
|
|
348
|
+
}
|
|
349
|
+
:global(.x):not(p) {
|
|
350
|
+
color: green;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
:global(span):not(p span) {
|
|
354
|
+
color: green;
|
|
355
|
+
}
|
|
356
|
+
span:not(:global(p span)) {
|
|
357
|
+
color: green;
|
|
358
|
+
}
|
|
359
|
+
:global(span:not(p span)) {
|
|
360
|
+
color: green;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
:global(.x) {
|
|
364
|
+
:not(.foo) {
|
|
365
|
+
color: green;
|
|
366
|
+
}
|
|
367
|
+
&:not(.foo) {
|
|
368
|
+
color: green;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
</style>
|
|
372
|
+
</>
|
|
373
|
+
}`;
|
|
344
374
|
const { css } = compile(source, 'test.tsrx');
|
|
345
375
|
|
|
346
376
|
expect(css).toContain(':not(.foo)');
|
|
@@ -349,33 +379,35 @@ export function Test() { return <>
|
|
|
349
379
|
|
|
350
380
|
it('handles sibling combinators with children and :global before scoped elements', () => {
|
|
351
381
|
const source = `
|
|
352
|
-
export function Test({ children }) {
|
|
353
|
-
|
|
354
|
-
<
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
<
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
382
|
+
export function Test({ children }) @{
|
|
383
|
+
<>
|
|
384
|
+
<div>
|
|
385
|
+
<p class="before">{'before'}</p>
|
|
386
|
+
|
|
387
|
+
{children}
|
|
388
|
+
|
|
389
|
+
<p class="foo">
|
|
390
|
+
<span>{'foo'}</span>
|
|
391
|
+
</p>
|
|
392
|
+
<p class="bar">{'bar'}</p>
|
|
393
|
+
</div>
|
|
394
|
+
|
|
395
|
+
<style>
|
|
396
|
+
.before + .foo { color: green; }
|
|
397
|
+
.before ~ .foo { color: green; }
|
|
398
|
+
.before ~ .bar { color: green; }
|
|
399
|
+
|
|
400
|
+
:global(.x) + .foo { color: green; }
|
|
401
|
+
:global(.x) + .foo span { color: green; }
|
|
402
|
+
:global(.x) ~ .foo { color: green; }
|
|
403
|
+
:global(.x) ~ .foo span { color: green; }
|
|
404
|
+
:global(.x) ~ .bar { color: green; }
|
|
405
|
+
|
|
406
|
+
/* should be unused as this is not a possibility */
|
|
407
|
+
:global(.x) + .bar { color: green; }
|
|
408
|
+
</style>
|
|
409
|
+
</>
|
|
410
|
+
}`;
|
|
379
411
|
const { css } = compile(source, 'test.tsrx');
|
|
380
412
|
|
|
381
413
|
expect(css).toMatch(/\.before\.tsrx-[a-z0-9]+ \+ \.foo:where\(\.tsrx-[a-z0-9]+\) {/);
|
|
@@ -386,37 +418,39 @@ export function Test({ children }) { return <>
|
|
|
386
418
|
|
|
387
419
|
it('handles sibling combinators with component and :global before scoped elements', () => {
|
|
388
420
|
const source = `
|
|
389
|
-
export function Test({ children }) {
|
|
390
|
-
|
|
391
|
-
<
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
<
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
421
|
+
export function Test({ children }) @{
|
|
422
|
+
<>
|
|
423
|
+
<div>
|
|
424
|
+
<p class="before">{'before'}</p>
|
|
425
|
+
|
|
426
|
+
<Child1 />
|
|
427
|
+
|
|
428
|
+
<p class="foo">
|
|
429
|
+
<span>{'foo'}</span>
|
|
430
|
+
</p>
|
|
431
|
+
<p class="bar">{'bar'}</p>
|
|
432
|
+
</div>
|
|
433
|
+
|
|
434
|
+
<style>
|
|
435
|
+
.before + .foo { color: green; }
|
|
436
|
+
.before ~ .foo { color: green; }
|
|
437
|
+
.before ~ .bar { color: green; }
|
|
438
|
+
|
|
439
|
+
:global(.x) + .foo { color: green; }
|
|
440
|
+
:global(.x) + .foo span { color: green; }
|
|
441
|
+
:global(.x) ~ .foo { color: green; }
|
|
442
|
+
:global(.x) ~ .foo span { color: green; }
|
|
443
|
+
:global(.x) ~ .bar { color: green; }
|
|
444
|
+
|
|
445
|
+
/* should be unused as this is not a possibility */
|
|
446
|
+
:global(.x) + .bar { color: green; }
|
|
447
|
+
</style>
|
|
448
|
+
</>
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function Child1() @{
|
|
418
452
|
<div>{'child1'}</div>
|
|
419
|
-
|
|
453
|
+
}`;
|
|
420
454
|
const { css } = compile(source, 'test.tsrx');
|
|
421
455
|
|
|
422
456
|
expect(css).toMatch(/\.before\.tsrx-[a-z0-9]+ \+ \.foo:where\(\.tsrx-[a-z0-9]+\) {/);
|
|
@@ -429,40 +463,42 @@ function Child1() { return <>
|
|
|
429
463
|
'handles sibling combinators with dynamic component and :global before scoped elements',
|
|
430
464
|
() => {
|
|
431
465
|
const source = `
|
|
432
|
-
import { track } from 'ripple';
|
|
466
|
+
import { Dynamic, track } from 'ripple';
|
|
433
467
|
|
|
434
|
-
export function Test({ children }) {
|
|
468
|
+
export function Test({ children }) @{
|
|
435
469
|
const DynamicComponent = track(() => Child1);
|
|
436
|
-
|
|
437
|
-
<
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
<
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
470
|
+
<>
|
|
471
|
+
<div>
|
|
472
|
+
<p class="before">{'before'}</p>
|
|
473
|
+
|
|
474
|
+
<Dynamic is={DynamicComponent} />
|
|
475
|
+
|
|
476
|
+
<p class="foo">
|
|
477
|
+
<span>{'foo'}</span>
|
|
478
|
+
</p>
|
|
479
|
+
<p class="bar">{'bar'}</p>
|
|
480
|
+
</div>
|
|
481
|
+
|
|
482
|
+
<style>
|
|
483
|
+
.before + .foo { color: green; }
|
|
484
|
+
.before ~ .foo { color: green; }
|
|
485
|
+
.before ~ .bar { color: green; }
|
|
486
|
+
|
|
487
|
+
:global(.x) + .foo { color: green; }
|
|
488
|
+
:global(.x) + .foo span { color: green; }
|
|
489
|
+
:global(.x) ~ .foo { color: green; }
|
|
490
|
+
:global(.x) ~ .foo span { color: green; }
|
|
491
|
+
:global(.x) ~ .bar { color: green; }
|
|
492
|
+
|
|
493
|
+
/* should be unused as this is not a possibility */
|
|
494
|
+
:global(.x) + .bar { color: green; }
|
|
495
|
+
</style>
|
|
496
|
+
</>
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function Child1() @{
|
|
464
500
|
<div>{'child1'}</div>
|
|
465
|
-
|
|
501
|
+
}`;
|
|
466
502
|
const { css } = compile(source, 'test.tsrx');
|
|
467
503
|
|
|
468
504
|
expect(css).toMatch(/\.before\.tsrx-[a-z0-9]+ \+ \.foo:where\(\.tsrx-[a-z0-9]+\) {/);
|
|
@@ -476,36 +512,38 @@ function Child1() { return <>
|
|
|
476
512
|
'handles sibling combinators with dynamic element or regular element and :global before scoped elements',
|
|
477
513
|
() => {
|
|
478
514
|
const source = `
|
|
479
|
-
import { track } from 'ripple';
|
|
515
|
+
import { Dynamic, track } from 'ripple';
|
|
480
516
|
|
|
481
|
-
export function Test({ children, classes }) {
|
|
517
|
+
export function Test({ children, classes }) @{
|
|
482
518
|
const dynamicElement = track('div');
|
|
483
|
-
|
|
484
|
-
<
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
<
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
519
|
+
<>
|
|
520
|
+
<div>
|
|
521
|
+
<p class="before">{'before'}</p>
|
|
522
|
+
// Use Dynamic Element but it's the same with a regular one
|
|
523
|
+
<Dynamic is={dynamicElement} class={classes} />
|
|
524
|
+
|
|
525
|
+
<p class="foo">
|
|
526
|
+
<span>{'foo'}</span>
|
|
527
|
+
</p>
|
|
528
|
+
<p class="bar">{'bar'}</p>
|
|
529
|
+
</div>
|
|
530
|
+
|
|
531
|
+
<style>
|
|
532
|
+
.before + .foo { color: green; }
|
|
533
|
+
.before ~ .foo { color: green; }
|
|
534
|
+
.before ~ .bar { color: green; }
|
|
535
|
+
|
|
536
|
+
:global(.x) + .foo { color: green; }
|
|
537
|
+
:global(.x) + .foo span { color: green; }
|
|
538
|
+
:global(.x) ~ .foo { color: green; }
|
|
539
|
+
:global(.x) ~ .foo span { color: green; }
|
|
540
|
+
:global(.x) ~ .bar { color: green; }
|
|
541
|
+
|
|
542
|
+
/* should be unused as this is not a possibility */
|
|
543
|
+
:global(.x) + .bar { color: green; }
|
|
544
|
+
</style>
|
|
545
|
+
</>
|
|
546
|
+
}`;
|
|
509
547
|
|
|
510
548
|
const { css } = compile(source, 'test.tsrx');
|
|
511
549
|
|
|
@@ -518,19 +556,21 @@ export function Test({ children, classes }) { return <>
|
|
|
518
556
|
|
|
519
557
|
it('handles :global with multiple global descendants', () => {
|
|
520
558
|
const source = `
|
|
521
|
-
export function Test() {
|
|
522
|
-
|
|
523
|
-
<
|
|
524
|
-
<
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
559
|
+
export function Test() @{
|
|
560
|
+
<>
|
|
561
|
+
<div class="root">
|
|
562
|
+
<section class="whatever">
|
|
563
|
+
<p>{'hello'}</p>
|
|
564
|
+
</section>
|
|
565
|
+
</div>
|
|
566
|
+
|
|
567
|
+
<style>
|
|
568
|
+
:global(html) :global(body) .root p {
|
|
569
|
+
color: red;
|
|
570
|
+
}
|
|
571
|
+
</style>
|
|
572
|
+
</>
|
|
573
|
+
}`;
|
|
534
574
|
const { css } = compile(source, 'test.tsrx');
|
|
535
575
|
|
|
536
576
|
expect(css).toMatch(/html body \.root\.tsrx-[a-z0-9]+ p:where\(\.tsrx-[a-z0-9]+\) {/);
|
|
@@ -538,25 +578,27 @@ export function Test() { return <>
|
|
|
538
578
|
|
|
539
579
|
it('handles nested @media with :global blocks', () => {
|
|
540
580
|
const source = `
|
|
541
|
-
export function Test() {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
:
|
|
550
|
-
|
|
551
|
-
|
|
581
|
+
export function Test() @{
|
|
582
|
+
<>
|
|
583
|
+
<div>{'content'}</div>
|
|
584
|
+
|
|
585
|
+
<style>
|
|
586
|
+
div {
|
|
587
|
+
color: black;
|
|
588
|
+
|
|
589
|
+
@media (min-width: 768px) {
|
|
590
|
+
:global {
|
|
591
|
+
.foo {
|
|
592
|
+
color: red;
|
|
593
|
+
}
|
|
552
594
|
}
|
|
553
|
-
}
|
|
554
595
|
|
|
555
|
-
|
|
596
|
+
color: blue;
|
|
597
|
+
}
|
|
556
598
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
599
|
+
</style>
|
|
600
|
+
</>
|
|
601
|
+
}`;
|
|
560
602
|
const { css } = compile(source, 'test.tsrx');
|
|
561
603
|
|
|
562
604
|
expect(css).toContain('@media (min-width: 768px) {');
|
|
@@ -566,28 +608,30 @@ export function Test() { return <>
|
|
|
566
608
|
|
|
567
609
|
it('handles :has with complex combinators', () => {
|
|
568
610
|
const source = `
|
|
569
|
-
export function Test() {
|
|
570
|
-
|
|
571
|
-
<
|
|
572
|
-
<
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
<
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
611
|
+
export function Test() @{
|
|
612
|
+
<>
|
|
613
|
+
<g>
|
|
614
|
+
<h>
|
|
615
|
+
<i>{'content'}</i>
|
|
616
|
+
</h>
|
|
617
|
+
<j>
|
|
618
|
+
<k>{'content'}</k>
|
|
619
|
+
</j>
|
|
620
|
+
</g>
|
|
621
|
+
|
|
622
|
+
<style>
|
|
623
|
+
g:has(> h > i) {
|
|
624
|
+
color: green;
|
|
625
|
+
}
|
|
626
|
+
h:has(> h > i) {
|
|
627
|
+
color: red;
|
|
628
|
+
}
|
|
629
|
+
g:has(+ j > k) {
|
|
630
|
+
color: green;
|
|
631
|
+
}
|
|
632
|
+
</style>
|
|
633
|
+
</>
|
|
634
|
+
}`;
|
|
591
635
|
const { css } = compile(source, 'test.tsrx');
|
|
592
636
|
|
|
593
637
|
expect(css).toMatch(
|
|
@@ -598,20 +642,22 @@ export function Test() { return <>
|
|
|
598
642
|
|
|
599
643
|
it('handles :global with attribute selectors containing special characters', () => {
|
|
600
644
|
const source = `
|
|
601
|
-
export function Test() {
|
|
602
|
-
|
|
603
|
-
<
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
645
|
+
export function Test() @{
|
|
646
|
+
<>
|
|
647
|
+
<div>
|
|
648
|
+
<h1 data-title="Hello, world!">{'hello world'}</h1>
|
|
649
|
+
</div>
|
|
650
|
+
|
|
651
|
+
<style>
|
|
652
|
+
div :global(h1[data-title="Hello, world!"]) {
|
|
653
|
+
color: red;
|
|
654
|
+
}
|
|
655
|
+
div :global(h1[attribute], video[autoplay]) {
|
|
656
|
+
color: red;
|
|
657
|
+
}
|
|
658
|
+
</style>
|
|
659
|
+
</>
|
|
660
|
+
}`;
|
|
615
661
|
const { css } = compile(source, 'test.tsrx');
|
|
616
662
|
|
|
617
663
|
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ h1\[data-title="Hello, world!"\]/);
|
|
@@ -620,17 +666,19 @@ export function Test() { return <>
|
|
|
620
666
|
|
|
621
667
|
it('handles escaped commas in :global class names', () => {
|
|
622
668
|
const source = `
|
|
623
|
-
export function Test() {
|
|
624
|
-
|
|
625
|
-
<
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
669
|
+
export function Test() @{
|
|
670
|
+
<>
|
|
671
|
+
<div>
|
|
672
|
+
<h1 class="h1,h2,h3">{'hello world'}</h1>
|
|
673
|
+
</div>
|
|
674
|
+
|
|
675
|
+
<style>
|
|
676
|
+
div :global(.h1\\,h2\\,h3) {
|
|
677
|
+
color: red;
|
|
678
|
+
}
|
|
679
|
+
</style>
|
|
680
|
+
</>
|
|
681
|
+
}`;
|
|
634
682
|
const { css } = compile(source, 'test.tsrx');
|
|
635
683
|
|
|
636
684
|
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ \.h1\\,h2\\,h3 {/);
|
|
@@ -641,21 +689,23 @@ export function Test() { return <>
|
|
|
641
689
|
*/
|
|
642
690
|
it('handles :global with :is containing multiple selectors', () => {
|
|
643
691
|
const source = `
|
|
644
|
-
export function Test() {
|
|
645
|
-
|
|
646
|
-
<
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
692
|
+
export function Test() @{
|
|
693
|
+
<>
|
|
694
|
+
<div>
|
|
695
|
+
<h1>{'hello world'}</h1>
|
|
696
|
+
<h2>{'subtitle'}</h2>
|
|
697
|
+
</div>
|
|
698
|
+
|
|
699
|
+
<style>
|
|
700
|
+
div :global(:is(h1, h2)) {
|
|
701
|
+
color: red;
|
|
702
|
+
}
|
|
703
|
+
div :global(:where(h1, h2)) {
|
|
704
|
+
color: red;
|
|
705
|
+
}
|
|
706
|
+
</style>
|
|
707
|
+
</>
|
|
708
|
+
}`;
|
|
659
709
|
const { css } = compile(source, 'test.tsrx');
|
|
660
710
|
|
|
661
711
|
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ :is\(h1, h2\)/);
|
|
@@ -664,19 +714,21 @@ export function Test() { return <>
|
|
|
664
714
|
|
|
665
715
|
it('handles :global with :is containing compound selectors', () => {
|
|
666
716
|
const source = `
|
|
667
|
-
export function Test() {
|
|
668
|
-
|
|
669
|
-
<
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
717
|
+
export function Test() @{
|
|
718
|
+
<>
|
|
719
|
+
<div>
|
|
720
|
+
<h1>{'hello world'}</h1>
|
|
721
|
+
<h2>{'subtitle'}</h2>
|
|
722
|
+
<h3>{'sub-subtitle'}</h3>
|
|
723
|
+
</div>
|
|
724
|
+
|
|
725
|
+
<style>
|
|
726
|
+
div :global(h1 ~ :is(h2, h3)) {
|
|
727
|
+
color: red;
|
|
728
|
+
}
|
|
729
|
+
</style>
|
|
730
|
+
</>
|
|
731
|
+
}`;
|
|
680
732
|
const { css } = compile(source, 'test.tsrx');
|
|
681
733
|
|
|
682
734
|
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ h1 ~ :is\(h2, h3\)/);
|
|
@@ -684,20 +736,22 @@ export function Test() { return <>
|
|
|
684
736
|
|
|
685
737
|
it('handles :global with pseudo-elements', () => {
|
|
686
738
|
const source = `
|
|
687
|
-
export function Test() {
|
|
688
|
-
|
|
689
|
-
<
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
739
|
+
export function Test() @{
|
|
740
|
+
<>
|
|
741
|
+
<div>
|
|
742
|
+
<h1 class="foo">{'hello world'}</h1>
|
|
743
|
+
</div>
|
|
744
|
+
|
|
745
|
+
<style>
|
|
746
|
+
.foo :global(.bar)::after {
|
|
747
|
+
color: red;
|
|
748
|
+
}
|
|
749
|
+
.foo :global(.bar)::after .baz {
|
|
750
|
+
color: red;
|
|
751
|
+
}
|
|
752
|
+
</style>
|
|
753
|
+
</>
|
|
754
|
+
}`;
|
|
701
755
|
expect(() => compile(source, 'test.tsrx')).toThrow(
|
|
702
756
|
':global(...) can be at the start or end of a selector sequence, but not in the middle',
|
|
703
757
|
);
|