ripple 0.3.71 → 0.3.74
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 +75 -0
- package/package.json +3 -3
- package/src/jsx-runtime.d.ts +2 -8
- package/src/runtime/index-client.js +3 -13
- package/src/runtime/internal/client/blocks.js +3 -25
- package/src/runtime/internal/client/for.js +80 -5
- package/src/runtime/internal/client/index.js +0 -2
- package/src/runtime/internal/client/types.d.ts +0 -10
- 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 +59 -71
- package/tests/client/basic/basic.components.test.tsrx +196 -222
- package/tests/client/basic/basic.errors.test.tsrx +72 -78
- 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.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 +364 -296
- 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 +41 -44
- 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 +491 -437
- 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 +62 -69
- package/tests/client/date.test.tsrx +83 -83
- package/tests/client/dynamic-elements.test.tsrx +227 -283
- package/tests/client/events.test.tsrx +252 -266
- package/tests/client/for.test.tsrx +120 -127
- package/tests/client/head.test.tsrx +40 -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 +195 -215
- 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 +290 -371
- 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 +396 -325
- 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 -286
- 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 +120 -167
- package/tests/server/basic.components.test.tsrx +163 -197
- package/tests/server/basic.test.tsrx +298 -220
- 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 +103 -135
- package/tests/server/for.test.tsrx +115 -84
- package/tests/server/head.test.tsrx +31 -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 +58 -66
- 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 +1 -0
- package/src/runtime/internal/client/compat.js +0 -40
- package/tests/utils/compiler-compat-config.test.js +0 -38
|
@@ -3,15 +3,17 @@ import { compile } from '@tsrx/ripple';
|
|
|
3
3
|
describe('CSS :global edge cases', () => {
|
|
4
4
|
it('handles multiple :global selectors in one rule', () => {
|
|
5
5
|
const source = `
|
|
6
|
-
export function Test() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
export function Test() @{
|
|
7
|
+
<>
|
|
8
|
+
<div>{'content'}</div>
|
|
9
|
+
|
|
10
|
+
<style>
|
|
11
|
+
:global(div), :global(span), p {
|
|
12
|
+
color: red;
|
|
13
|
+
}
|
|
14
|
+
</style>
|
|
15
|
+
</>
|
|
16
|
+
}`;
|
|
15
17
|
const { css } = compile(source, 'test.tsrx');
|
|
16
18
|
|
|
17
19
|
expect(css).toContain('div, span ');
|
|
@@ -20,19 +22,21 @@ export function Test() { return <>
|
|
|
20
22
|
|
|
21
23
|
it('handles :global with attribute selectors', () => {
|
|
22
24
|
const source = `
|
|
23
|
-
export function Test() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
export function Test() @{
|
|
26
|
+
<>
|
|
27
|
+
<div data-test="value">{'content'}</div>
|
|
28
|
+
|
|
29
|
+
<style>
|
|
30
|
+
:global([data-test]) {
|
|
31
|
+
color: red;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
div:global([data-foo="bar"]) {
|
|
35
|
+
color: blue;
|
|
36
|
+
}
|
|
37
|
+
</style>
|
|
38
|
+
</>
|
|
39
|
+
}`;
|
|
36
40
|
const { css } = compile(source, 'test.tsrx');
|
|
37
41
|
|
|
38
42
|
expect(css).toContain('[data-test] {');
|
|
@@ -41,19 +45,21 @@ export function Test() { return <>
|
|
|
41
45
|
|
|
42
46
|
it('handles :global with universal selector', () => {
|
|
43
47
|
const source = `
|
|
44
|
-
export function Test() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
export function Test() @{
|
|
49
|
+
<>
|
|
50
|
+
<div>{'content'}</div>
|
|
51
|
+
|
|
52
|
+
<style>
|
|
53
|
+
:global(*) {
|
|
54
|
+
box-sizing: border-box;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
div :global(*) {
|
|
58
|
+
margin: 0;
|
|
59
|
+
}
|
|
60
|
+
</style>
|
|
61
|
+
</>
|
|
62
|
+
}`;
|
|
57
63
|
const { css } = compile(source, 'test.tsrx');
|
|
58
64
|
|
|
59
65
|
expect(css).toContain('* {');
|
|
@@ -62,19 +68,21 @@ export function Test() { return <>
|
|
|
62
68
|
|
|
63
69
|
it('handles :global with ID selectors', () => {
|
|
64
70
|
const source = `
|
|
65
|
-
export function Test() {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
export function Test() @{
|
|
72
|
+
<>
|
|
73
|
+
<div id="test">{'content'}</div>
|
|
74
|
+
|
|
75
|
+
<style>
|
|
76
|
+
:global(#app) {
|
|
77
|
+
width: 100%;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
div :global(#test) {
|
|
81
|
+
color: red;
|
|
82
|
+
}
|
|
83
|
+
</style>
|
|
84
|
+
</>
|
|
85
|
+
}`;
|
|
78
86
|
const { css } = compile(source, 'test.tsrx');
|
|
79
87
|
|
|
80
88
|
expect(css).toContain('#app {');
|
|
@@ -85,19 +93,21 @@ export function Test() { return <>
|
|
|
85
93
|
|
|
86
94
|
it('handles :global with pseudo-elements', () => {
|
|
87
95
|
const source = `
|
|
88
|
-
export function Test() {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
export function Test() @{
|
|
97
|
+
<>
|
|
98
|
+
<div>{'content'}</div>
|
|
99
|
+
|
|
100
|
+
<style>
|
|
101
|
+
:global(div)::before {
|
|
102
|
+
content: "before";
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
div :global(span)::after {
|
|
106
|
+
content: "after";
|
|
107
|
+
}
|
|
108
|
+
</style>
|
|
109
|
+
</>
|
|
110
|
+
}`;
|
|
101
111
|
const { css } = compile(source, 'test.tsrx');
|
|
102
112
|
|
|
103
113
|
expect(css).toContain('div::before {');
|
|
@@ -107,17 +117,19 @@ export function Test() { return <>
|
|
|
107
117
|
|
|
108
118
|
it('handles empty :global blocks', () => {
|
|
109
119
|
const source = `
|
|
110
|
-
export function Test() {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
export function Test() @{
|
|
121
|
+
<>
|
|
122
|
+
<div>{'content'}</div>
|
|
123
|
+
|
|
124
|
+
<style>
|
|
125
|
+
div {
|
|
126
|
+
:global {
|
|
127
|
+
}
|
|
128
|
+
color: red;
|
|
116
129
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
</>; }`;
|
|
130
|
+
</style>
|
|
131
|
+
</>
|
|
132
|
+
}`;
|
|
121
133
|
const { css } = compile(source, 'test.tsrx');
|
|
122
134
|
|
|
123
135
|
expect(css).toContain('color: red');
|
|
@@ -126,23 +138,25 @@ export function Test() { return <>
|
|
|
126
138
|
|
|
127
139
|
it('handles :global with complex selector chains', () => {
|
|
128
140
|
const source = `
|
|
129
|
-
export function Test() {
|
|
130
|
-
|
|
131
|
-
<
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
export function Test() @{
|
|
142
|
+
<>
|
|
143
|
+
<div class="container">
|
|
144
|
+
<span class="wrapper foo">
|
|
145
|
+
<button class="bar"><span>{'click'}</span></button>
|
|
146
|
+
</span>
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<style>
|
|
150
|
+
:global(div.container) > span.wrapper + :global(button[disabled]) {
|
|
151
|
+
color: red;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
:global(.foo > .bar) span {
|
|
155
|
+
color: blue;
|
|
156
|
+
}
|
|
157
|
+
</style>
|
|
158
|
+
</>
|
|
159
|
+
}`;
|
|
146
160
|
const { css } = compile(source, 'test.tsrx');
|
|
147
161
|
|
|
148
162
|
expect(css).toMatch(/div\.container > span.wrapper\.tsrx-[a-z0-9]+ \+ button\[disabled\] {/);
|
|
@@ -151,19 +165,21 @@ export function Test() { return <>
|
|
|
151
165
|
|
|
152
166
|
it('rejects :global in the middle of a selector sequence', () => {
|
|
153
167
|
const source = `
|
|
154
|
-
export function Test() {
|
|
155
|
-
|
|
156
|
-
<
|
|
157
|
-
<
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
168
|
+
export function Test() @{
|
|
169
|
+
<>
|
|
170
|
+
<div>
|
|
171
|
+
<span class="foo">
|
|
172
|
+
<button class="bar">{'click'}</button>
|
|
173
|
+
</span>
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
<style>
|
|
177
|
+
div :global(.foo > .bar) span {
|
|
178
|
+
color: red;
|
|
179
|
+
}
|
|
180
|
+
</style>
|
|
181
|
+
</>
|
|
182
|
+
}`;
|
|
167
183
|
|
|
168
184
|
expect(() => compile(source, 'test.tsrx')).toThrow(
|
|
169
185
|
':global(...) can be at the start or end of a selector sequence, but not in the middle',
|
|
@@ -172,25 +188,27 @@ export function Test() { return <>
|
|
|
172
188
|
|
|
173
189
|
it('handles :global at start and end of selector', () => {
|
|
174
190
|
const source = `
|
|
175
|
-
export function Test() {
|
|
176
|
-
|
|
177
|
-
<
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
export function Test() @{
|
|
192
|
+
<>
|
|
193
|
+
<div>
|
|
194
|
+
<span>{'content'}</span>
|
|
195
|
+
</div>
|
|
196
|
+
|
|
197
|
+
<style>
|
|
198
|
+
:global(html) div span {
|
|
199
|
+
color: red;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
div span :global(strong) {
|
|
203
|
+
color: blue;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
:global(body) div :global(em) {
|
|
207
|
+
color: green;
|
|
208
|
+
}
|
|
209
|
+
</style>
|
|
210
|
+
</>
|
|
211
|
+
}`;
|
|
194
212
|
const { css } = compile(source, 'test.tsrx');
|
|
195
213
|
|
|
196
214
|
expect(css).toMatch(/html div\.tsrx-[a-z0-9]+ span:where\(\.tsrx-[a-z0-9]+\) {/);
|
|
@@ -3,20 +3,22 @@ import { compile } from '@tsrx/ripple';
|
|
|
3
3
|
describe('CSS :global with keyframes', () => {
|
|
4
4
|
it('handles -global- prefix for keyframes', () => {
|
|
5
5
|
const source = `
|
|
6
|
-
export function Test() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
export function Test() @{
|
|
7
|
+
<>
|
|
8
|
+
<div>{'animated'}</div>
|
|
9
|
+
|
|
10
|
+
<style>
|
|
11
|
+
@keyframes -global-foo {
|
|
12
|
+
0% { opacity: 0; }
|
|
13
|
+
100% { opacity: 1; }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
div {
|
|
17
|
+
animation: foo 1s;
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
20
|
+
</>
|
|
21
|
+
}`;
|
|
20
22
|
const { css } = compile(source, 'test.tsrx');
|
|
21
23
|
|
|
22
24
|
expect(css).toContain('@keyframes foo');
|
|
@@ -26,16 +28,18 @@ export function Test() { return <>
|
|
|
26
28
|
|
|
27
29
|
it('handles scoped keyframes without -global- prefix', () => {
|
|
28
30
|
const source = `
|
|
29
|
-
export function Test() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
export function Test() @{
|
|
32
|
+
<>
|
|
33
|
+
<div>{'animated'}</div>
|
|
34
|
+
|
|
35
|
+
<style>
|
|
36
|
+
@keyframes foo {
|
|
37
|
+
0% { opacity: 0; }
|
|
38
|
+
100% { opacity: 1; }
|
|
39
|
+
}
|
|
40
|
+
</style>
|
|
41
|
+
</>
|
|
42
|
+
}`;
|
|
39
43
|
const { css } = compile(source, 'test.tsrx');
|
|
40
44
|
|
|
41
45
|
expect(css).toMatch(/@keyframes tsrx-[a-z0-9]+-foo/);
|
|
@@ -43,30 +47,32 @@ export function Test() { return <>
|
|
|
43
47
|
|
|
44
48
|
it('handles mix of global and scoped keyframes', () => {
|
|
45
49
|
const source = `
|
|
46
|
-
export function Test() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
50
|
+
export function Test() @{
|
|
51
|
+
<>
|
|
52
|
+
<div class="global-anim">{'one'}</div>
|
|
53
|
+
<div class="scoped-anim">{'two'}</div>
|
|
54
|
+
|
|
55
|
+
<style>
|
|
56
|
+
@keyframes -global-fadeIn {
|
|
57
|
+
0% { opacity: 0; }
|
|
58
|
+
100% { opacity: 1; }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@keyframes slideIn {
|
|
62
|
+
0% { transform: translateX(-100%); }
|
|
63
|
+
100% { transform: translateX(0); }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.global-anim {
|
|
67
|
+
animation: fadeIn 1s;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.scoped-anim {
|
|
71
|
+
animation: slideIn 1s;
|
|
72
|
+
}
|
|
73
|
+
</style>
|
|
74
|
+
</>
|
|
75
|
+
}`;
|
|
70
76
|
const { css } = compile(source, 'test.tsrx');
|
|
71
77
|
|
|
72
78
|
expect(css).toContain('@keyframes fadeIn');
|
|
@@ -78,21 +84,23 @@ export function Test() { return <>
|
|
|
78
84
|
|
|
79
85
|
it('handles multiple animations with global keyframes', () => {
|
|
80
86
|
const source = `
|
|
81
|
-
export function Test() {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
87
|
+
export function Test() @{
|
|
88
|
+
<>
|
|
89
|
+
<div>{'animated'}</div>
|
|
90
|
+
|
|
91
|
+
<style>
|
|
92
|
+
@keyframes -global-foo {
|
|
93
|
+
0% { opacity: 0; }
|
|
94
|
+
100% { opacity: 1; }
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@keyframes -global-bar {
|
|
98
|
+
0% { transform: scale(0); }
|
|
99
|
+
100% { transform: scale(1); }
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
102
|
+
</>
|
|
103
|
+
}`;
|
|
96
104
|
const { css } = compile(source, 'test.tsrx');
|
|
97
105
|
|
|
98
106
|
expect(css).toContain('@keyframes foo');
|
|
@@ -101,39 +109,43 @@ export function Test() { return <>
|
|
|
101
109
|
|
|
102
110
|
it('handles animation property referencing keyframes (not marking as unused)', () => {
|
|
103
111
|
const source = `
|
|
104
|
-
export function Parent() {
|
|
105
|
-
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
112
|
+
export function Parent() @{
|
|
113
|
+
<>
|
|
114
|
+
<div class="parent">
|
|
115
|
+
<Child />
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
<style>
|
|
119
|
+
/* Scoped keyframe - only usable within Parent */
|
|
120
|
+
@keyframes slideIn {
|
|
121
|
+
from { transform: translateX(-100%); }
|
|
122
|
+
to { transform: translateX(0); }
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* Global keyframe - usable in any component */
|
|
126
|
+
@keyframes -global-fadeIn {
|
|
127
|
+
0% { opacity: 0; }
|
|
128
|
+
100% { opacity: 1; }
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.parent {
|
|
132
|
+
animation: slideIn 1s;
|
|
133
|
+
}
|
|
134
|
+
</style>
|
|
135
|
+
</>
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function Child() @{
|
|
139
|
+
<>
|
|
140
|
+
<div class="child">{'Child content'}</div>
|
|
141
|
+
|
|
142
|
+
<style>
|
|
143
|
+
.child {
|
|
144
|
+
animation: fadeIn 3s; /* Uses global fadeIn from Parent */
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
147
|
+
</>
|
|
148
|
+
}`;
|
|
137
149
|
const { css } = compile(source, 'test.tsrx');
|
|
138
150
|
|
|
139
151
|
// Parent should have scoped slideIn and global fadeIn
|