ripple 0.3.20 → 0.3.21
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 +7 -0
- package/package.json +2 -2
- package/tests/client/basic/basic.attributes.test.tsrx +4 -10
- package/tests/client/composite/composite.render.test.tsrx +4 -6
- package/tests/client/css/global-additional-cases.test.tsrx +27 -27
- package/tests/client/css/global-advanced-selectors.test.tsrx +2 -2
- package/tests/client/css/global-at-rules.test.tsrx +5 -5
- package/tests/client/css/global-basic.test.tsrx +8 -8
- package/tests/client/css/global-classes-ids.test.tsrx +13 -13
- package/tests/client/css/global-combinators.test.tsrx +8 -8
- package/tests/client/css/global-complex-nesting.test.tsrx +19 -19
- package/tests/client/css/global-edge-cases.test.tsrx +12 -12
- package/tests/client/css/global-keyframes.test.tsrx +7 -7
- package/tests/client/css/global-nested.test.tsrx +10 -10
- package/tests/client/css/global-pseudo.test.tsrx +7 -7
- package/tests/client/css/global-scoping.test.tsrx +20 -20
- package/tests/client/css/style-identifier.test.tsrx +7 -7
- package/tests/client/dynamic-elements.test.tsrx +14 -14
- package/tests/server/basic.attributes.test.tsrx +4 -10
- package/tests/server/dynamic-elements.test.tsrx +11 -11
- package/tests/server/style-identifier.test.tsrx +12 -14
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Ripple is an elegant TypeScript UI framework",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dominic Gannaway",
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.21",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"module": "src/runtime/index-client.js",
|
|
9
9
|
"main": "src/runtime/index-client.js",
|
|
@@ -83,6 +83,6 @@
|
|
|
83
83
|
"@tsrx/ripple": "0.0.5"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
|
-
"ripple": "0.3.
|
|
86
|
+
"ripple": "0.3.21"
|
|
87
87
|
}
|
|
88
88
|
}
|
|
@@ -37,9 +37,7 @@ describe('basic client > attribute rendering', () => {
|
|
|
37
37
|
const button = container.querySelector('button');
|
|
38
38
|
const div = container.querySelector('div');
|
|
39
39
|
|
|
40
|
-
expect(Array.from(div.classList).some((className) => className.startsWith('
|
|
41
|
-
true,
|
|
42
|
-
);
|
|
40
|
+
expect(Array.from(div.classList).some((className) => className.startsWith('tsrx-'))).toBe(true);
|
|
43
41
|
expect(div.classList.contains('inactive')).toBe(true);
|
|
44
42
|
|
|
45
43
|
button.click();
|
|
@@ -82,9 +80,7 @@ describe('basic client > attribute rendering', () => {
|
|
|
82
80
|
|
|
83
81
|
const div = container.querySelector('div');
|
|
84
82
|
|
|
85
|
-
expect(Array.from(div.classList).some((className) => className.startsWith('
|
|
86
|
-
true,
|
|
87
|
-
);
|
|
83
|
+
expect(Array.from(div.classList).some((className) => className.startsWith('tsrx-'))).toBe(true);
|
|
88
84
|
expect(div.classList.contains('foo')).toBe(true);
|
|
89
85
|
expect(div.classList.contains('bar')).toBe(true);
|
|
90
86
|
expect(div.classList.contains('baz')).toBe(true);
|
|
@@ -121,9 +117,7 @@ describe('basic client > attribute rendering', () => {
|
|
|
121
117
|
const button = container.querySelector('button');
|
|
122
118
|
const div = container.querySelector('div');
|
|
123
119
|
|
|
124
|
-
expect(Array.from(div.classList).some((className) => className.startsWith('
|
|
125
|
-
true,
|
|
126
|
-
);
|
|
120
|
+
expect(Array.from(div.classList).some((className) => className.startsWith('tsrx-'))).toBe(true);
|
|
127
121
|
expect(div.classList.contains('inactive')).toBe(true);
|
|
128
122
|
expect(div.classList.contains('active')).toBe(false);
|
|
129
123
|
|
|
@@ -162,7 +156,7 @@ describe('basic client > attribute rendering', () => {
|
|
|
162
156
|
const divs = container.querySelectorAll('div');
|
|
163
157
|
|
|
164
158
|
divs.forEach((div) => {
|
|
165
|
-
expect(Array.from(div.classList).some((className) => className.startsWith('
|
|
159
|
+
expect(Array.from(div.classList).some((className) => className.startsWith('tsrx-'))).toBe(
|
|
166
160
|
true,
|
|
167
161
|
);
|
|
168
162
|
});
|
|
@@ -137,10 +137,8 @@ describe('composite > render', () => {
|
|
|
137
137
|
|
|
138
138
|
const wrapper = container.querySelector('.green');
|
|
139
139
|
const child = container.querySelector('.red');
|
|
140
|
-
const wrapper_scopes = Array.from(wrapper.classList).filter(
|
|
141
|
-
|
|
142
|
-
);
|
|
143
|
-
const child_scopes = Array.from(child.classList).filter((name) => name.startsWith('ripple-'));
|
|
140
|
+
const wrapper_scopes = Array.from(wrapper.classList).filter((name) => name.startsWith('tsrx-'));
|
|
141
|
+
const child_scopes = Array.from(child.classList).filter((name) => name.startsWith('tsrx-'));
|
|
144
142
|
|
|
145
143
|
expect(wrapper_scopes).toHaveLength(1);
|
|
146
144
|
expect(child_scopes).toHaveLength(1);
|
|
@@ -230,8 +228,8 @@ describe('scoped styles with children', () => {
|
|
|
230
228
|
const wrapper = container.querySelector('.green');
|
|
231
229
|
const child = container.querySelector('.red');
|
|
232
230
|
|
|
233
|
-
const wrapper_classes = Array.from(wrapper.classList).filter((c) => c.startsWith('
|
|
234
|
-
const child_classes = Array.from(child.classList).filter((c) => c.startsWith('
|
|
231
|
+
const wrapper_classes = Array.from(wrapper.classList).filter((c) => c.startsWith('tsrx-'));
|
|
232
|
+
const child_classes = Array.from(child.classList).filter((c) => c.startsWith('tsrx-'));
|
|
235
233
|
|
|
236
234
|
expect(wrapper_classes).toHaveLength(1);
|
|
237
235
|
expect(child_classes).toHaveLength(1);
|
|
@@ -15,7 +15,7 @@ export component Test() {
|
|
|
15
15
|
}`;
|
|
16
16
|
const { css } = compile(source, 'test.tsrx');
|
|
17
17
|
|
|
18
|
-
expect(css).toMatch(/div\.
|
|
18
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+\.x {/);
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
it('handles :global modifier in nested syntax', () => {
|
|
@@ -67,7 +67,7 @@ export component Test() {
|
|
|
67
67
|
}`;
|
|
68
68
|
const { css } = compile(source, 'test.tsrx');
|
|
69
69
|
|
|
70
|
-
expect(css).toMatch(/div\.
|
|
70
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+:is\(html\.dark-mode \*\) {/);
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
it('handles :global with & inside :global block', () => {
|
|
@@ -85,7 +85,7 @@ export component Test() {
|
|
|
85
85
|
}`;
|
|
86
86
|
const { css } = compile(source, 'test.tsrx');
|
|
87
87
|
|
|
88
|
-
expect(css).toMatch(/div\.
|
|
88
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ {/);
|
|
89
89
|
expect(css).toContain('&.class {');
|
|
90
90
|
});
|
|
91
91
|
|
|
@@ -105,7 +105,7 @@ export component Test() {
|
|
|
105
105
|
const { css } = compile(source, 'test.tsrx');
|
|
106
106
|
|
|
107
107
|
expect(css).toContain('* {');
|
|
108
|
-
expect(css).toMatch(/&:hover \.class\.
|
|
108
|
+
expect(css).toMatch(/&:hover \.class\.tsrx-[a-z0-9]+ {/);
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
it('handles multiple :global selectors in list', () => {
|
|
@@ -142,7 +142,7 @@ export component Test() {
|
|
|
142
142
|
}`;
|
|
143
143
|
const { css } = compile(source, 'test.tsrx');
|
|
144
144
|
|
|
145
|
-
expect(css).toMatch(/div\.
|
|
145
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+/);
|
|
146
146
|
expect(css).toContain('z {');
|
|
147
147
|
});
|
|
148
148
|
|
|
@@ -180,8 +180,8 @@ export component Test() {
|
|
|
180
180
|
expect(css).toContain('@keyframes test-in {');
|
|
181
181
|
expect(css).toContain('.x {');
|
|
182
182
|
expect(css).toContain('.y {');
|
|
183
|
-
expect(css).toMatch(/@keyframes
|
|
184
|
-
expect(css).not.toMatch(/\.x\.
|
|
183
|
+
expect(css).toMatch(/@keyframes tsrx-[a-z0-9]+-test/);
|
|
184
|
+
expect(css).not.toMatch(/\.x\.tsrx-[a-z0-9]+/);
|
|
185
185
|
});
|
|
186
186
|
|
|
187
187
|
it('handles global keyframes with no component elements', () => {
|
|
@@ -222,9 +222,9 @@ export component Test() {
|
|
|
222
222
|
}`;
|
|
223
223
|
const { css } = compile(source, 'test.tsrx');
|
|
224
224
|
|
|
225
|
-
expect(css).toMatch(/div\.
|
|
226
|
-
expect(css).toMatch(/span\.blue\.x\.
|
|
227
|
-
expect(css).toMatch(/span\.x\.
|
|
225
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+\.blue {/);
|
|
226
|
+
expect(css).toMatch(/span\.blue\.x\.tsrx-[a-z0-9]+ {/);
|
|
227
|
+
expect(css).toMatch(/span\.x\.tsrx-[a-z0-9]+\.bg {/);
|
|
228
228
|
});
|
|
229
229
|
|
|
230
230
|
it('handles multiple :global() in descendant sequence', () => {
|
|
@@ -241,7 +241,7 @@ export component Test() {
|
|
|
241
241
|
const { css } = compile(source, 'test.tsrx');
|
|
242
242
|
|
|
243
243
|
expect(css).toContain('div > section > p');
|
|
244
|
-
expect(css).toMatch(/p\.
|
|
244
|
+
expect(css).toMatch(/p\.tsrx-[a-z0-9]+ {/);
|
|
245
245
|
});
|
|
246
246
|
|
|
247
247
|
it('handles :is with :global and html context', () => {
|
|
@@ -261,7 +261,7 @@ export component Test() {
|
|
|
261
261
|
}`;
|
|
262
262
|
const { css } = compile(source, 'test.tsrx');
|
|
263
263
|
|
|
264
|
-
expect(css).toMatch(/x\.
|
|
264
|
+
expect(css).toMatch(/x\.tsrx-[a-z0-9]+ :is\(html \*\) {/);
|
|
265
265
|
});
|
|
266
266
|
|
|
267
267
|
it('handles :global block with :has inside', () => {
|
|
@@ -289,9 +289,9 @@ export component Test() {
|
|
|
289
289
|
const { css } = compile(source, 'test.tsrx');
|
|
290
290
|
|
|
291
291
|
expect(css).toContain('.foo {');
|
|
292
|
-
expect(css).toMatch(/\.
|
|
293
|
-
expect(css).toMatch(/&:has\(x\.
|
|
294
|
-
expect(css).toMatch(/.foo:has\(x\.
|
|
292
|
+
expect(css).toMatch(/\.tsrx-[a-z0-9]+:has\(x:where\(\.tsrx-[a-z0-9]+\)\) {/);
|
|
293
|
+
expect(css).toMatch(/&:has\(x\.tsrx-[a-z0-9]+\) {/);
|
|
294
|
+
expect(css).toMatch(/.foo:has\(x\.tsrx-[a-z0-9]+\) {/);
|
|
295
295
|
});
|
|
296
296
|
|
|
297
297
|
it('handles :not with :global in complex nesting', () => {
|
|
@@ -378,7 +378,7 @@ export component Test({ children }) {
|
|
|
378
378
|
}`;
|
|
379
379
|
const { css } = compile(source, 'test.tsrx');
|
|
380
380
|
|
|
381
|
-
expect(css).toMatch(/\.before\.
|
|
381
|
+
expect(css).toMatch(/\.before\.tsrx-[a-z0-9]+ \+ \.foo:where\(\.tsrx-[a-z0-9]+\) {/);
|
|
382
382
|
expect((css.match(/\.x\ /g) || []).length).toBe(0);
|
|
383
383
|
expect((css.match(/\(unused\) :global\(\.x\) /g) || []).length).toBe(6);
|
|
384
384
|
expect(css).toContain('(unused) :global(.x) + .bar {');
|
|
@@ -419,7 +419,7 @@ component Child1() {
|
|
|
419
419
|
}`;
|
|
420
420
|
const { css } = compile(source, 'test.tsrx');
|
|
421
421
|
|
|
422
|
-
expect(css).toMatch(/\.before\.
|
|
422
|
+
expect(css).toMatch(/\.before\.tsrx-[a-z0-9]+ \+ \.foo:where\(\.tsrx-[a-z0-9]+\) {/);
|
|
423
423
|
expect((css.match(/\.x\ /g) || []).length).toBe(5);
|
|
424
424
|
expect((css.match(/\(unused\) :global\(\.x\) /g) || []).length).toBe(1);
|
|
425
425
|
expect(css).toContain('(unused) :global(.x) + .bar {');
|
|
@@ -465,7 +465,7 @@ component Child1() {
|
|
|
465
465
|
}`;
|
|
466
466
|
const { css } = compile(source, 'test.tsrx');
|
|
467
467
|
|
|
468
|
-
expect(css).toMatch(/\.before\.
|
|
468
|
+
expect(css).toMatch(/\.before\.tsrx-[a-z0-9]+ \+ \.foo:where\(\.tsrx-[a-z0-9]+\) {/);
|
|
469
469
|
expect((css.match(/\.x\ /g) || []).length).toBe(5);
|
|
470
470
|
expect((css.match(/\(unused\) :global\(\.x\) /g) || []).length).toBe(1);
|
|
471
471
|
expect(css).toContain('(unused) :global(.x) + .bar {');
|
|
@@ -509,7 +509,7 @@ export component Test({ children, classes }) {
|
|
|
509
509
|
|
|
510
510
|
const { css } = compile(source, 'test.tsrx');
|
|
511
511
|
|
|
512
|
-
expect(css).toMatch(/\.before\.
|
|
512
|
+
expect(css).toMatch(/\.before\.tsrx-[a-z0-9]+ \+ \.foo:where\(\.tsrx-[a-z0-9]+\) {/);
|
|
513
513
|
expect((css.match(/\.x\ /g) || []).length).toBe(5);
|
|
514
514
|
expect((css.match(/\(unused\) :global\(\.x\) /g) || []).length).toBe(1);
|
|
515
515
|
expect(css).toContain('(unused) :global(.x) + .bar {');
|
|
@@ -533,7 +533,7 @@ export component Test() {
|
|
|
533
533
|
}`;
|
|
534
534
|
const { css } = compile(source, 'test.tsrx');
|
|
535
535
|
|
|
536
|
-
expect(css).toMatch(/html body \.root\.
|
|
536
|
+
expect(css).toMatch(/html body \.root\.tsrx-[a-z0-9]+ p:where\(\.tsrx-[a-z0-9]+\) {/);
|
|
537
537
|
});
|
|
538
538
|
|
|
539
539
|
it('handles nested @media with :global blocks', () => {
|
|
@@ -561,7 +561,7 @@ export component Test() {
|
|
|
561
561
|
|
|
562
562
|
expect(css).toContain('@media (min-width: 768px) {');
|
|
563
563
|
expect(css).toContain('.foo {');
|
|
564
|
-
expect(css).not.toMatch(/\.foo\.
|
|
564
|
+
expect(css).not.toMatch(/\.foo\.tsrx-[a-z0-9]+/);
|
|
565
565
|
});
|
|
566
566
|
|
|
567
567
|
it('handles :has with complex combinators', () => {
|
|
@@ -591,7 +591,7 @@ export component Test() {
|
|
|
591
591
|
const { css } = compile(source, 'test.tsrx');
|
|
592
592
|
|
|
593
593
|
expect(css).toMatch(
|
|
594
|
-
/g\.
|
|
594
|
+
/g\.tsrx-[a-z0-9]+:has\(> h:where\(\.tsrx-[a-z0-9]+\) > i:where\(\.tsrx-[a-z0-9]+\)\)/,
|
|
595
595
|
);
|
|
596
596
|
expect(css).toContain('(unused) h:has(> h > i)');
|
|
597
597
|
});
|
|
@@ -614,7 +614,7 @@ export component Test() {
|
|
|
614
614
|
}`;
|
|
615
615
|
const { css } = compile(source, 'test.tsrx');
|
|
616
616
|
|
|
617
|
-
expect(css).toMatch(/div\.
|
|
617
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ h1\[data-title="Hello, world!"\]/);
|
|
618
618
|
expect(css).toContain('h1[attribute], video[autoplay]');
|
|
619
619
|
});
|
|
620
620
|
|
|
@@ -633,7 +633,7 @@ export component Test() {
|
|
|
633
633
|
}`;
|
|
634
634
|
const { css } = compile(source, 'test.tsrx');
|
|
635
635
|
|
|
636
|
-
expect(css).toMatch(/div\.
|
|
636
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ \.h1\\,h2\\,h3 {/);
|
|
637
637
|
});
|
|
638
638
|
|
|
639
639
|
/**
|
|
@@ -658,8 +658,8 @@ export component Test() {
|
|
|
658
658
|
}`;
|
|
659
659
|
const { css } = compile(source, 'test.tsrx');
|
|
660
660
|
|
|
661
|
-
expect(css).toMatch(/div\.
|
|
662
|
-
expect(css).toMatch(/div\.
|
|
661
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ :is\(h1, h2\)/);
|
|
662
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ :where\(h1, h2\)/);
|
|
663
663
|
});
|
|
664
664
|
|
|
665
665
|
it('handles :global with :is containing compound selectors', () => {
|
|
@@ -679,7 +679,7 @@ export component Test() {
|
|
|
679
679
|
}`;
|
|
680
680
|
const { css } = compile(source, 'test.tsrx');
|
|
681
681
|
|
|
682
|
-
expect(css).toMatch(/div\.
|
|
682
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ h1 ~ :is\(h2, h3\)/);
|
|
683
683
|
});
|
|
684
684
|
|
|
685
685
|
it('handles :global with pseudo-elements', () => {
|
|
@@ -20,7 +20,7 @@ export component Test() {
|
|
|
20
20
|
}`;
|
|
21
21
|
const { css } = compile(source, 'test.tsrx');
|
|
22
22
|
|
|
23
|
-
expect(css).toMatch(/div\.
|
|
23
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ ::slotted\(span\) {/);
|
|
24
24
|
expect(css).toContain('::slotted(*) {');
|
|
25
25
|
});
|
|
26
26
|
|
|
@@ -41,7 +41,7 @@ export component Test() {
|
|
|
41
41
|
}`;
|
|
42
42
|
const { css } = compile(source, 'test.tsrx');
|
|
43
43
|
|
|
44
|
-
expect(css).toMatch(/div\.
|
|
44
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ ::part\(input\) {/);
|
|
45
45
|
expect(css).toContain('::part(button) {');
|
|
46
46
|
});
|
|
47
47
|
|
|
@@ -22,7 +22,7 @@ export component Test() {
|
|
|
22
22
|
|
|
23
23
|
expect(css).toContain('@media (min-width: 768px) {');
|
|
24
24
|
expect(css).toContain('div {');
|
|
25
|
-
expect(css).toMatch(/div\.
|
|
25
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ span {/);
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
it('handles :global inside @supports queries', () => {
|
|
@@ -46,7 +46,7 @@ export component Test() {
|
|
|
46
46
|
|
|
47
47
|
expect(css).toContain('@supports (display: grid) {');
|
|
48
48
|
expect(css).toContain('.container {');
|
|
49
|
-
expect(css).toMatch(/div\.
|
|
49
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ \.item {/);
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
it('handles nested @media with :global', () => {
|
|
@@ -74,8 +74,8 @@ export component Test() {
|
|
|
74
74
|
|
|
75
75
|
expect(css).toContain('@media (min-width: 768px) {');
|
|
76
76
|
expect(css).toContain('.foo {');
|
|
77
|
-
expect(css).not.toMatch(/\.foo\.
|
|
78
|
-
expect(css).toMatch(/div\.
|
|
77
|
+
expect(css).not.toMatch(/\.foo\.tsrx-[a-z0-9]+/);
|
|
78
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ {/);
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
it('handles :global in @container queries', () => {
|
|
@@ -121,6 +121,6 @@ export component Test() {
|
|
|
121
121
|
expect(css).toContain('@media screen {');
|
|
122
122
|
expect(css).toContain('@supports (display: flex) {');
|
|
123
123
|
expect(css).toContain('.flex-container {');
|
|
124
|
-
expect(css).toMatch(/div\.
|
|
124
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ \.flex-item {/);
|
|
125
125
|
});
|
|
126
126
|
});
|
|
@@ -16,7 +16,7 @@ export component Test() {
|
|
|
16
16
|
|
|
17
17
|
expect(css).toContain('div {');
|
|
18
18
|
expect(css).toContain('color: red;');
|
|
19
|
-
expect(css).not.toMatch(/div\.
|
|
19
|
+
expect(css).not.toMatch(/div\.tsrx-[a-z0-9]+/);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it('applies global selector with class', () => {
|
|
@@ -38,7 +38,7 @@ export component Test() {
|
|
|
38
38
|
|
|
39
39
|
expect(css).toContain('div.foo {');
|
|
40
40
|
expect(css).toContain('.foo {');
|
|
41
|
-
expect(css).not.toMatch(/\.foo\.
|
|
41
|
+
expect(css).not.toMatch(/\.foo\.tsrx-[a-z0-9]+/);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
it('mixes global and local selectors', () => {
|
|
@@ -62,7 +62,7 @@ export component Test() {
|
|
|
62
62
|
|
|
63
63
|
expect(css).toContain('div .foo');
|
|
64
64
|
expect(css).toContain('div > .foo');
|
|
65
|
-
expect(css).toMatch(/\.foo\.
|
|
65
|
+
expect(css).toMatch(/\.foo\.tsrx-[a-z0-9]+/);
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
it('handles global block syntax', () => {
|
|
@@ -86,7 +86,7 @@ export component Test() {
|
|
|
86
86
|
|
|
87
87
|
expect(css).toContain('.x {');
|
|
88
88
|
expect(css).toContain('.a, .selector, .list {');
|
|
89
|
-
expect(css).not.toMatch(/\.x\.
|
|
89
|
+
expect(css).not.toMatch(/\.x\.tsrx-[a-z0-9]+/);
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
it('handles global with pseudo-classes', () => {
|
|
@@ -108,7 +108,7 @@ export component Test() {
|
|
|
108
108
|
|
|
109
109
|
expect(css).toContain('button:hover {');
|
|
110
110
|
expect(css).toContain('button:focus {');
|
|
111
|
-
expect(css).not.toMatch(/button\.
|
|
111
|
+
expect(css).not.toMatch(/button\.tsrx-[a-z0-9]+/);
|
|
112
112
|
});
|
|
113
113
|
|
|
114
114
|
it('handles multiple global selectors in selector list', () => {
|
|
@@ -157,9 +157,9 @@ export component Test() {
|
|
|
157
157
|
}`;
|
|
158
158
|
const { css } = compile(source, 'test.tsrx');
|
|
159
159
|
|
|
160
|
-
expect(css).toMatch(/\.styled-container\.
|
|
161
|
-
expect(css).toMatch(/\.text\.
|
|
160
|
+
expect(css).toMatch(/\.styled-container\.tsrx-[a-z0-9]+/);
|
|
161
|
+
expect(css).toMatch(/\.text\.tsrx-[a-z0-9]+/);
|
|
162
162
|
expect(css).toContain('h1 {');
|
|
163
|
-
expect(css).not.toMatch(/h1\.
|
|
163
|
+
expect(css).not.toMatch(/h1\.tsrx-[a-z0-9]+/);
|
|
164
164
|
});
|
|
165
165
|
});
|
|
@@ -15,7 +15,7 @@ export component Test() {
|
|
|
15
15
|
const { css } = compile(source, 'test.tsrx');
|
|
16
16
|
|
|
17
17
|
expect(css).toContain('.foo {');
|
|
18
|
-
expect(css).not.toMatch(/\.foo\.
|
|
18
|
+
expect(css).not.toMatch(/\.foo\.tsrx-[a-z0-9]+/);
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
it('handles :global with chained classes', () => {
|
|
@@ -40,8 +40,8 @@ export component Test() {
|
|
|
40
40
|
const { css } = compile(source, 'test.tsrx');
|
|
41
41
|
|
|
42
42
|
expect(css).toContain('.foo.bar {');
|
|
43
|
-
expect(css).toMatch(/\.foo\.bar\.
|
|
44
|
-
expect(css).toMatch(/\.foo\.
|
|
43
|
+
expect(css).toMatch(/\.foo\.bar\.tsrx-[a-z0-9]+ {/);
|
|
44
|
+
expect(css).toMatch(/\.foo\.tsrx-[a-z0-9]+\.bar {/);
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
it('handles local class inside :global selector', () => {
|
|
@@ -63,7 +63,7 @@ export component Test() {
|
|
|
63
63
|
}`;
|
|
64
64
|
const { css } = compile(source, 'test.tsrx');
|
|
65
65
|
|
|
66
|
-
expect(css).toMatch(/\.outer \.inner\.
|
|
66
|
+
expect(css).toMatch(/\.outer \.inner\.tsrx-[a-z0-9]+ {/);
|
|
67
67
|
expect(css).toMatch(/\(unused\) :global\(div\) \.foo {/);
|
|
68
68
|
});
|
|
69
69
|
|
|
@@ -92,8 +92,8 @@ export component Test() {
|
|
|
92
92
|
|
|
93
93
|
expect(css).toContain('#app {');
|
|
94
94
|
expect(css).not.toContain('#app #content {');
|
|
95
|
-
expect(css).not.toMatch(/#app\.
|
|
96
|
-
expect(css).toMatch(/div\.
|
|
95
|
+
expect(css).not.toMatch(/#app\.tsrx-[a-z0-9]+/);
|
|
96
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ #content {/);
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
it('handles :global with class and ID combination', () => {
|
|
@@ -118,8 +118,8 @@ export component Test() {
|
|
|
118
118
|
const { css } = compile(source, 'test.tsrx');
|
|
119
119
|
|
|
120
120
|
expect(css).toContain('#app.container {');
|
|
121
|
-
expect(css).toMatch(/\.container#app\.
|
|
122
|
-
expect(css).toMatch(/#app\.
|
|
121
|
+
expect(css).toMatch(/\.container#app\.tsrx-[a-z0-9]+ {/);
|
|
122
|
+
expect(css).toMatch(/#app\.tsrx-[a-z0-9]+\.container {/);
|
|
123
123
|
});
|
|
124
124
|
|
|
125
125
|
it('handles multiple classes with :global', () => {
|
|
@@ -143,8 +143,8 @@ export component Test() {
|
|
|
143
143
|
}`;
|
|
144
144
|
const { css } = compile(source, 'test.tsrx');
|
|
145
145
|
|
|
146
|
-
expect((css.match(/\.a\.b\.c\.
|
|
147
|
-
expect(css).toMatch(/\.a\.b\.
|
|
146
|
+
expect((css.match(/\.a\.b\.c\.tsrx-[a-z0-9]+ {/g) || []).length).toBe(2);
|
|
147
|
+
expect(css).toMatch(/\.a\.b\.tsrx-[a-z0-9]+\.c {/);
|
|
148
148
|
});
|
|
149
149
|
|
|
150
150
|
it('handles :global with class descendant selectors', () => {
|
|
@@ -172,8 +172,8 @@ export component Test() {
|
|
|
172
172
|
}`;
|
|
173
173
|
const { css } = compile(source, 'test.tsrx');
|
|
174
174
|
|
|
175
|
-
expect(css).toMatch(/\.outer \.middle\.
|
|
176
|
-
expect(css).toMatch(/\.outer\.
|
|
177
|
-
expect(css).toMatch(/\.outer\.
|
|
175
|
+
expect(css).toMatch(/\.outer \.middle\.tsrx-[a-z0-9]+ \.inner:where\(\.tsrx-[a-z0-9]+\)/);
|
|
176
|
+
expect(css).toMatch(/\.outer\.tsrx-[a-z0-9]+ \.middle \.inner {/);
|
|
177
|
+
expect(css).toMatch(/\.outer\.tsrx-[a-z0-9]+ \.middle:where\(\.tsrx-[a-z0-9]+\)\.inner/);
|
|
178
178
|
});
|
|
179
179
|
});
|
|
@@ -16,8 +16,8 @@ export component Test() {
|
|
|
16
16
|
}`;
|
|
17
17
|
const { css } = compile(source, 'test.tsrx');
|
|
18
18
|
|
|
19
|
-
expect(css).toMatch(/div\.
|
|
20
|
-
expect(css).not.toMatch(/span\.
|
|
19
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ > span {/);
|
|
20
|
+
expect(css).not.toMatch(/span\.tsrx-[a-z0-9]+/);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
it('handles :global with adjacent sibling combinator', () => {
|
|
@@ -40,7 +40,7 @@ export component Test() {
|
|
|
40
40
|
}`;
|
|
41
41
|
const { css } = compile(source, 'test.tsrx');
|
|
42
42
|
|
|
43
|
-
expect(css).toMatch(/span\.
|
|
43
|
+
expect(css).toMatch(/span\.tsrx-[a-z0-9]+ \+ span {/);
|
|
44
44
|
expect(css).toContain('(unused) :global(div) + span {');
|
|
45
45
|
});
|
|
46
46
|
|
|
@@ -66,7 +66,7 @@ export component Test() {
|
|
|
66
66
|
|
|
67
67
|
expect(css).toContain('~');
|
|
68
68
|
|
|
69
|
-
expect(css).toMatch(/span\.
|
|
69
|
+
expect(css).toMatch(/span\.tsrx-[a-z0-9]+ ~ span {/);
|
|
70
70
|
expect(css).toMatch('(unused) :global(div) ~ span {');
|
|
71
71
|
});
|
|
72
72
|
|
|
@@ -92,8 +92,8 @@ export component Test() {
|
|
|
92
92
|
}`;
|
|
93
93
|
const { css } = compile(source, 'test.tsrx');
|
|
94
94
|
|
|
95
|
-
expect(css).toMatch(/div\.
|
|
96
|
-
expect(css).toMatch(/div > span\.
|
|
95
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ > span > button {/);
|
|
96
|
+
expect(css).toMatch(/div > span\.tsrx-[a-z0-9]+ \+ button:where\(\.tsrx-[a-z0-9]+\) {/);
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
it('handles :global with descendant combinator', () => {
|
|
@@ -118,7 +118,7 @@ export component Test() {
|
|
|
118
118
|
|
|
119
119
|
const { css } = compile(source, 'test.tsrx');
|
|
120
120
|
|
|
121
|
-
expect(css).toMatch(/div\.
|
|
122
|
-
expect(css).toMatch(/div span\.
|
|
121
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ span button {/);
|
|
122
|
+
expect(css).toMatch(/div span\.tsrx-[a-z0-9]+ button:where\(\.tsrx-[a-z0-9]+\) {/);
|
|
123
123
|
});
|
|
124
124
|
});
|
|
@@ -26,9 +26,9 @@ export component Test() {
|
|
|
26
26
|
}`;
|
|
27
27
|
const { css } = compile(source, 'test.tsrx');
|
|
28
28
|
|
|
29
|
-
expect(css).not.toMatch(/div\.
|
|
30
|
-
expect(css).not.toMatch(/span\.
|
|
31
|
-
expect(css).not.toMatch(/button\.
|
|
29
|
+
expect(css).not.toMatch(/div\.tsrx-[a-z0-9]+ {/);
|
|
30
|
+
expect(css).not.toMatch(/span\.tsrx-[a-z0-9]+ {/);
|
|
31
|
+
expect(css).not.toMatch(/button\.tsrx-[a-z0-9]+ {/);
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
it('handles local block with :global nested inside', () => {
|
|
@@ -54,8 +54,8 @@ export component Test() {
|
|
|
54
54
|
}`;
|
|
55
55
|
const { css } = compile(source, 'test.tsrx');
|
|
56
56
|
|
|
57
|
-
expect(css).toMatch(/div\.
|
|
58
|
-
expect(css).not.toMatch(/span\.
|
|
57
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ {/);
|
|
58
|
+
expect(css).not.toMatch(/span\.tsrx-[a-z0-9]+ {/);
|
|
59
59
|
expect(css).toContain('(unused) p {');
|
|
60
60
|
});
|
|
61
61
|
|
|
@@ -82,8 +82,8 @@ export component Test() {
|
|
|
82
82
|
|
|
83
83
|
expect(css).toContain('div {');
|
|
84
84
|
expect(css).toContain('.local {');
|
|
85
|
-
expect(css).not.toMatch(/div\.
|
|
86
|
-
expect(css).not.toMatch(/\.local\.
|
|
85
|
+
expect(css).not.toMatch(/div\.tsrx-[a-z0-9]+ {/);
|
|
86
|
+
expect(css).not.toMatch(/\.local\.tsrx-[a-z0-9]+ {/);
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
it('handles alternating :global and local nesting', () => {
|
|
@@ -111,8 +111,8 @@ export component Test() {
|
|
|
111
111
|
}`;
|
|
112
112
|
const { css } = compile(source, 'test.tsrx');
|
|
113
113
|
|
|
114
|
-
expect(css).toMatch(/div\.
|
|
115
|
-
expect(css).toMatch(/button\.
|
|
114
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ {/);
|
|
115
|
+
expect(css).toMatch(/button\.tsrx-[a-z0-9]+ {/);
|
|
116
116
|
expect(css).toContain('span {');
|
|
117
117
|
expect(css).toContain('em {');
|
|
118
118
|
});
|
|
@@ -142,11 +142,11 @@ export component Test() {
|
|
|
142
142
|
}`;
|
|
143
143
|
const { css } = compile(source, 'test.tsrx');
|
|
144
144
|
|
|
145
|
-
expect(css).toMatch(/div\.
|
|
145
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ {/);
|
|
146
146
|
expect(css).toContain('span {');
|
|
147
147
|
expect(css).toContain('button {');
|
|
148
|
-
expect(css).not.toMatch(/span\.
|
|
149
|
-
expect(css).not.toMatch(/button\.
|
|
148
|
+
expect(css).not.toMatch(/span\.tsrx-[a-z0-9]+/);
|
|
149
|
+
expect(css).not.toMatch(/button\.tsrx-[a-z0-9]+/);
|
|
150
150
|
});
|
|
151
151
|
|
|
152
152
|
it('handles :global with nesting combinator &', () => {
|
|
@@ -174,8 +174,8 @@ export component Test() {
|
|
|
174
174
|
}`;
|
|
175
175
|
const { css } = compile(source, 'test.tsrx');
|
|
176
176
|
|
|
177
|
-
expect(css).toMatch(/\.container\.
|
|
178
|
-
expect(css).toMatch(/button\.
|
|
177
|
+
expect(css).toMatch(/\.container\.tsrx-[a-z0-9]+ {/);
|
|
178
|
+
expect(css).toMatch(/button\.tsrx-[a-z0-9]+ {/);
|
|
179
179
|
expect(css).toContain('&.active {');
|
|
180
180
|
expect(css).toContain('&.pressed {');
|
|
181
181
|
});
|
|
@@ -209,13 +209,13 @@ export component Test() {
|
|
|
209
209
|
}`;
|
|
210
210
|
const { css } = compile(source, 'test.tsrx');
|
|
211
211
|
|
|
212
|
-
expect(css).toMatch(/div\.
|
|
213
|
-
expect(css).toMatch(/ul\.
|
|
214
|
-
expect(css).toMatch(/a\.
|
|
212
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ {/);
|
|
213
|
+
expect(css).toMatch(/ul\.tsrx-[a-z0-9]+ {/);
|
|
214
|
+
expect(css).toMatch(/a\.tsrx-[a-z0-9]+ {/);
|
|
215
215
|
|
|
216
216
|
expect(css).toContain('nav {');
|
|
217
217
|
expect(css).toContain('li {');
|
|
218
|
-
expect(css).not.toMatch(/nav\.
|
|
219
|
-
expect(css).not.toMatch(/li\.
|
|
218
|
+
expect(css).not.toMatch(/nav\.tsrx-[a-z0-9]+ {/);
|
|
219
|
+
expect(css).not.toMatch(/li\.tsrx-[a-z0-9]+ {/);
|
|
220
220
|
});
|
|
221
221
|
});
|
|
@@ -36,7 +36,7 @@ export component Test() {
|
|
|
36
36
|
const { css } = compile(source, 'test.tsrx');
|
|
37
37
|
|
|
38
38
|
expect(css).toContain('[data-test] {');
|
|
39
|
-
expect(css).toMatch(/div\.
|
|
39
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+\[data-foo="bar"\]/);
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
it('handles :global with universal selector', () => {
|
|
@@ -57,7 +57,7 @@ export component Test() {
|
|
|
57
57
|
const { css } = compile(source, 'test.tsrx');
|
|
58
58
|
|
|
59
59
|
expect(css).toContain('* {');
|
|
60
|
-
expect(css).toMatch(/div\.
|
|
60
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ \* {/);
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
it('handles :global with ID selectors', () => {
|
|
@@ -78,9 +78,9 @@ export component Test() {
|
|
|
78
78
|
const { css } = compile(source, 'test.tsrx');
|
|
79
79
|
|
|
80
80
|
expect(css).toContain('#app {');
|
|
81
|
-
expect(css).toMatch(/div\.
|
|
82
|
-
expect(css).not.toMatch(/#app\.
|
|
83
|
-
expect(css).not.toMatch(/#test\.
|
|
81
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ #test {/);
|
|
82
|
+
expect(css).not.toMatch(/#app\.tsrx-[a-z0-9]+/);
|
|
83
|
+
expect(css).not.toMatch(/#test\.tsrx-[a-z0-9]+/);
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
it('handles :global with pseudo-elements', () => {
|
|
@@ -102,7 +102,7 @@ export component Test() {
|
|
|
102
102
|
|
|
103
103
|
expect(css).toContain('div::before {');
|
|
104
104
|
``;
|
|
105
|
-
expect(css).toMatch(/div\.
|
|
105
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ span::after {/);
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
it('handles empty :global blocks', () => {
|
|
@@ -121,7 +121,7 @@ export component Test() {
|
|
|
121
121
|
const { css } = compile(source, 'test.tsrx');
|
|
122
122
|
|
|
123
123
|
expect(css).toContain('color: red');
|
|
124
|
-
expect(css).toMatch(/div\.
|
|
124
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ {/);
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
it('handles :global with complex selector chains', () => {
|
|
@@ -145,8 +145,8 @@ export component Test() {
|
|
|
145
145
|
}`;
|
|
146
146
|
const { css } = compile(source, 'test.tsrx');
|
|
147
147
|
|
|
148
|
-
expect(css).toMatch(/div\.container > span.wrapper\.
|
|
149
|
-
expect(css).toMatch(/\.foo > \.bar span\.
|
|
148
|
+
expect(css).toMatch(/div\.container > span.wrapper\.tsrx-[a-z0-9]+ \+ button\[disabled\] {/);
|
|
149
|
+
expect(css).toMatch(/\.foo > \.bar span\.tsrx-[a-z0-9]+ {/);
|
|
150
150
|
});
|
|
151
151
|
|
|
152
152
|
it('rejects :global in the middle of a selector sequence', () => {
|
|
@@ -193,8 +193,8 @@ export component Test() {
|
|
|
193
193
|
}`;
|
|
194
194
|
const { css } = compile(source, 'test.tsrx');
|
|
195
195
|
|
|
196
|
-
expect(css).toMatch(/html div\.
|
|
197
|
-
expect(css).toMatch(/div\.
|
|
198
|
-
expect(css).toMatch(/body div\.
|
|
196
|
+
expect(css).toMatch(/html div\.tsrx-[a-z0-9]+ span:where\(\.tsrx-[a-z0-9]+\) {/);
|
|
197
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ span:where\(\.tsrx-[a-z0-9]+\) strong {/);
|
|
198
|
+
expect(css).toMatch(/body div\.tsrx-[a-z0-9]+ em {/);
|
|
199
199
|
});
|
|
200
200
|
});
|
|
@@ -38,7 +38,7 @@ export component Test() {
|
|
|
38
38
|
}`;
|
|
39
39
|
const { css } = compile(source, 'test.tsrx');
|
|
40
40
|
|
|
41
|
-
expect(css).toMatch(/@keyframes
|
|
41
|
+
expect(css).toMatch(/@keyframes tsrx-[a-z0-9]+-foo/);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
it('handles mix of global and scoped keyframes', () => {
|
|
@@ -71,9 +71,9 @@ export component Test() {
|
|
|
71
71
|
|
|
72
72
|
expect(css).toContain('@keyframes fadeIn');
|
|
73
73
|
expect(css).not.toContain('-global-fadeIn');
|
|
74
|
-
expect(css).toMatch(/@keyframes
|
|
75
|
-
expect(css).toMatch(/\.scoped-anim\.
|
|
76
|
-
expect(css).toMatch(/\.global-anim\.
|
|
74
|
+
expect(css).toMatch(/@keyframes tsrx-[a-z0-9]+-slideIn/);
|
|
75
|
+
expect(css).toMatch(/\.scoped-anim\.tsrx-[a-z0-9]+/);
|
|
76
|
+
expect(css).toMatch(/\.global-anim\.tsrx-[a-z0-9]+/);
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
it('handles multiple animations with global keyframes', () => {
|
|
@@ -137,20 +137,20 @@ component Child() {
|
|
|
137
137
|
const { css } = compile(source, 'test.tsrx');
|
|
138
138
|
|
|
139
139
|
// Parent should have scoped slideIn and global fadeIn
|
|
140
|
-
expect(css).toMatch(/@keyframes
|
|
140
|
+
expect(css).toMatch(/@keyframes tsrx-[a-z0-9]+-slideIn/);
|
|
141
141
|
expect(css).toContain('@keyframes fadeIn');
|
|
142
142
|
expect(css).not.toContain('-global-fadeIn');
|
|
143
143
|
|
|
144
144
|
// Parent .parent should reference scoped slideIn
|
|
145
145
|
expect(css).toMatch(
|
|
146
|
-
/\.parent\.
|
|
146
|
+
/\.parent\.tsrx-[a-z0-9]+\s*{[\s\S]*?animation:\s*tsrx-[a-z0-9]+-slideIn 1s/,
|
|
147
147
|
);
|
|
148
148
|
|
|
149
149
|
// .parent should NOT be marked as unused
|
|
150
150
|
expect(css).not.toContain('(unused) .parent');
|
|
151
151
|
|
|
152
152
|
// Child .child should reference global fadeIn
|
|
153
|
-
expect(css).toMatch(/\.child\.
|
|
153
|
+
expect(css).toMatch(/\.child\.tsrx-[a-z0-9]+\s*{[\s\S]*?animation:\s*fadeIn 3s/);
|
|
154
154
|
|
|
155
155
|
// .child should NOT be marked as unused
|
|
156
156
|
expect(css).not.toContain('(unused) .child');
|
|
@@ -34,12 +34,12 @@ export component Test() {
|
|
|
34
34
|
}`;
|
|
35
35
|
const { css } = compile(source, 'test.tsrx');
|
|
36
36
|
|
|
37
|
-
expect(css).toMatch(/div\.
|
|
37
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ {/);
|
|
38
38
|
expect(css).toContain('.x {');
|
|
39
39
|
expect(css).toContain('.y {');
|
|
40
|
-
expect(css).not.toMatch(/\.x\.
|
|
41
|
-
expect(css).not.toMatch(/\.y\.
|
|
42
|
-
expect(css).toMatch(/p\.
|
|
40
|
+
expect(css).not.toMatch(/\.x\.tsrx-[a-z0-9]+/);
|
|
41
|
+
expect(css).not.toMatch(/\.y\.tsrx-[a-z0-9]+/);
|
|
42
|
+
expect(css).toMatch(/p\.tsrx-[a-z0-9]+ \.y {/);
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
it('handles :global with nesting selector', () => {
|
|
@@ -70,7 +70,7 @@ export component Test() {
|
|
|
70
70
|
const { css } = compile(source, 'test.tsrx');
|
|
71
71
|
|
|
72
72
|
expect(css).toContain('&.x {');
|
|
73
|
-
expect(css).toMatch(/div\.
|
|
73
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+\.x {/);
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
it('handles global block with de-nested syntax', () => {
|
|
@@ -96,7 +96,7 @@ export component Test() {
|
|
|
96
96
|
|
|
97
97
|
expect(css).toContain('div {');
|
|
98
98
|
expect(css).toContain('.y {');
|
|
99
|
-
expect(css).toMatch(/div\.
|
|
99
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ p {/);
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
it('handles global local nested combinations', () => {
|
|
@@ -121,8 +121,8 @@ export component Test() {
|
|
|
121
121
|
const { css } = compile(source, 'test.tsrx');
|
|
122
122
|
|
|
123
123
|
expect(css).toContain('.whatever {');
|
|
124
|
-
expect(css).not.toMatch(/\.whatever\.
|
|
125
|
-
expect(css).toMatch(/div\.
|
|
124
|
+
expect(css).not.toMatch(/\.whatever\.tsrx-[a-z0-9]+ {/);
|
|
125
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ {/);
|
|
126
126
|
});
|
|
127
127
|
|
|
128
128
|
it('handles :global with :is and :where pseudoclasses', () => {
|
|
@@ -144,7 +144,7 @@ export component Test() {
|
|
|
144
144
|
}`;
|
|
145
145
|
const { css } = compile(source, 'test.tsrx');
|
|
146
146
|
|
|
147
|
-
expect(css).toMatch(/div\.
|
|
148
|
-
expect(css).toMatch(/\.foo :is\(div\.
|
|
147
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ :is\(span\) {/);
|
|
148
|
+
expect(css).toMatch(/\.foo :is\(div\.tsrx-[a-z0-9]+\) {/);
|
|
149
149
|
});
|
|
150
150
|
});
|
|
@@ -20,7 +20,7 @@ export component Test() {
|
|
|
20
20
|
}`;
|
|
21
21
|
const { css } = compile(source, 'test.tsrx');
|
|
22
22
|
|
|
23
|
-
expect(css).toMatch(/div\.
|
|
23
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+:has\(span\)/);
|
|
24
24
|
expect(css).toContain('div:has(span)');
|
|
25
25
|
});
|
|
26
26
|
|
|
@@ -44,7 +44,7 @@ export component Test() {
|
|
|
44
44
|
}`;
|
|
45
45
|
const { css } = compile(source, 'test.tsrx');
|
|
46
46
|
|
|
47
|
-
expect(css).toMatch(/div\.
|
|
47
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ :is\(span, p:where\(\.tsrx-[a-z0-9]+\)\) {/);
|
|
48
48
|
expect(css).not.toMatch(/span:where/);
|
|
49
49
|
expect(css).not.toMatch(/span\.ripple/);
|
|
50
50
|
expect(css).toContain('div:is(.foo, .bar)');
|
|
@@ -70,7 +70,7 @@ export component Test() {
|
|
|
70
70
|
}`;
|
|
71
71
|
const { css } = compile(source, 'test.tsrx');
|
|
72
72
|
|
|
73
|
-
expect(css).toMatch(/div\.
|
|
73
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ :where\(span, p:where\(\.tsrx-[a-z0-9]+\)\) {/);
|
|
74
74
|
expect(css).not.toMatch(/span:where/);
|
|
75
75
|
expect(css).not.toMatch(/span\.ripple/);
|
|
76
76
|
expect(css).toContain('div:where(.foo, .bar)');
|
|
@@ -95,7 +95,7 @@ export component Test() {
|
|
|
95
95
|
}`;
|
|
96
96
|
const { css } = compile(source, 'test.tsrx');
|
|
97
97
|
|
|
98
|
-
expect(css).toMatch(/div\.
|
|
98
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+:not\(span\)/);
|
|
99
99
|
expect(css).toContain('div:not(.foo)');
|
|
100
100
|
});
|
|
101
101
|
|
|
@@ -118,7 +118,7 @@ export component Test() {
|
|
|
118
118
|
}`;
|
|
119
119
|
const { css } = compile(source, 'test.tsrx');
|
|
120
120
|
|
|
121
|
-
expect(css).toMatch(/div\.
|
|
121
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+:is\(:where\(\.tsrx-[a-z0-9]+\):has\(span\)\) {/);
|
|
122
122
|
expect(css).toContain('div:where(:is(.foo))');
|
|
123
123
|
});
|
|
124
124
|
|
|
@@ -148,8 +148,8 @@ export component Test() {
|
|
|
148
148
|
const { css } = compile(source, 'test.tsrx');
|
|
149
149
|
|
|
150
150
|
expect(css).toContain('span:nth-child(2) {');
|
|
151
|
-
expect(css).toMatch(/div\.
|
|
151
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+ > span:first-child {/);
|
|
152
152
|
expect(css).toContain('div:last-child {');
|
|
153
|
-
expect(css).not.toMatch(/span\.
|
|
153
|
+
expect(css).not.toMatch(/span\.tsrx-[a-z0-9]+:nth-child/);
|
|
154
154
|
});
|
|
155
155
|
});
|
|
@@ -14,7 +14,7 @@ export component Test() {
|
|
|
14
14
|
}`;
|
|
15
15
|
const { css } = compile(source, 'test.tsrx');
|
|
16
16
|
|
|
17
|
-
expect(css).toMatch(/\.scoped\.
|
|
17
|
+
expect(css).toMatch(/\.scoped\.tsrx-[a-z0-9]+/);
|
|
18
18
|
expect(css).not.toContain('.scoped {');
|
|
19
19
|
});
|
|
20
20
|
|
|
@@ -32,7 +32,7 @@ export component Test() {
|
|
|
32
32
|
const { css } = compile(source, 'test.tsrx');
|
|
33
33
|
|
|
34
34
|
expect(css).toContain('.global {');
|
|
35
|
-
expect(css).not.toMatch(/\.global\.
|
|
35
|
+
expect(css).not.toMatch(/\.global\.tsrx-[a-z0-9]+/);
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
it('verifies mixed local and global maintain proper scoping', () => {
|
|
@@ -66,11 +66,11 @@ export component Test() {
|
|
|
66
66
|
}`;
|
|
67
67
|
const { css } = compile(source, 'test.tsrx');
|
|
68
68
|
|
|
69
|
-
expect(css).toMatch(/\.outer\.
|
|
69
|
+
expect(css).toMatch(/\.outer\.tsrx-[a-z0-9]+ {/);
|
|
70
70
|
expect(css).toMatch(/\.outer {/);
|
|
71
|
-
expect(css).toMatch(/\.outer\.
|
|
72
|
-
expect(css).toMatch(/\.outer \.inner\.
|
|
73
|
-
expect(css).toMatch(/\.outer\.
|
|
71
|
+
expect(css).toMatch(/\.outer\.tsrx-[a-z0-9]+ \.inner:where\(\.tsrx-[a-z0-9]+\) {/);
|
|
72
|
+
expect(css).toMatch(/\.outer \.inner\.tsrx-[a-z0-9]+/);
|
|
73
|
+
expect(css).toMatch(/\.outer\.tsrx-[a-z0-9]+ \.inner {/);
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
it('verifies :global blocks scope all nested selectors globally', () => {
|
|
@@ -103,9 +103,9 @@ export component Test() {
|
|
|
103
103
|
expect(css).toContain('div {');
|
|
104
104
|
expect(css).toContain('span {');
|
|
105
105
|
expect(css).toContain('button {');
|
|
106
|
-
expect(css).not.toMatch(/div\.
|
|
107
|
-
expect(css).not.toMatch(/span\.
|
|
108
|
-
expect(css).not.toMatch(/button\.
|
|
106
|
+
expect(css).not.toMatch(/div\.tsrx-[a-z0-9]+/);
|
|
107
|
+
expect(css).not.toMatch(/span\.tsrx-[a-z0-9]+/);
|
|
108
|
+
expect(css).not.toMatch(/button\.tsrx-[a-z0-9]+/);
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
it('verifies element selectors are scoped by default', () => {
|
|
@@ -133,9 +133,9 @@ export component Test() {
|
|
|
133
133
|
}`;
|
|
134
134
|
const { css } = compile(source, 'test.tsrx');
|
|
135
135
|
|
|
136
|
-
expect(css).toMatch(/div\.
|
|
137
|
-
expect(css).toMatch(/span\.
|
|
138
|
-
expect(css).toMatch(/button\.
|
|
136
|
+
expect(css).toMatch(/div\.tsrx-[a-z0-9]+/);
|
|
137
|
+
expect(css).toMatch(/span\.tsrx-[a-z0-9]+/);
|
|
138
|
+
expect(css).toMatch(/button\.tsrx-[a-z0-9]+/);
|
|
139
139
|
});
|
|
140
140
|
|
|
141
141
|
it('verifies :global() escapes only the wrapped selector', () => {
|
|
@@ -155,8 +155,8 @@ export component Test() {
|
|
|
155
155
|
}`;
|
|
156
156
|
const { css } = compile(source, 'test.tsrx');
|
|
157
157
|
|
|
158
|
-
expect(css).toMatch(/\.local\.
|
|
159
|
-
expect(css).not.toMatch(/\.global\.
|
|
158
|
+
expect(css).toMatch(/\.local\.tsrx-[a-z0-9]+ \.global \.local {/);
|
|
159
|
+
expect(css).not.toMatch(/\.global\.tsrx-[a-z0-9]+/);
|
|
160
160
|
});
|
|
161
161
|
|
|
162
162
|
it('verifies multiple components have different scope hashes', () => {
|
|
@@ -183,11 +183,11 @@ export component Test2() {
|
|
|
183
183
|
const { css: css1 } = compile(source1, 'test1.tsrx');
|
|
184
184
|
const { css: css2 } = compile(source2, 'test2.tsrx');
|
|
185
185
|
|
|
186
|
-
expect(css1).toMatch(/\.test\.
|
|
187
|
-
expect(css2).toMatch(/\.test\.
|
|
186
|
+
expect(css1).toMatch(/\.test\.tsrx-[a-z0-9]+/);
|
|
187
|
+
expect(css2).toMatch(/\.test\.tsrx-[a-z0-9]+/);
|
|
188
188
|
|
|
189
|
-
const hash1Match = css1.match(/\.test\.
|
|
190
|
-
const hash2Match = css2.match(/\.test\.
|
|
189
|
+
const hash1Match = css1.match(/\.test\.tsrx-([a-z0-9]+)/);
|
|
190
|
+
const hash2Match = css2.match(/\.test\.tsrx-([a-z0-9]+)/);
|
|
191
191
|
|
|
192
192
|
expect(hash1Match).toBeTruthy();
|
|
193
193
|
expect(hash2Match).toBeTruthy();
|
|
@@ -222,8 +222,8 @@ export component Test2() {
|
|
|
222
222
|
const { css: css2 } = compile(source2, 'test2.tsrx');
|
|
223
223
|
|
|
224
224
|
expect(css1).toContain('.global {');
|
|
225
|
-
expect(css1).not.toMatch(/\.global\.
|
|
225
|
+
expect(css1).not.toMatch(/\.global\.tsrx-[a-z0-9]+/);
|
|
226
226
|
expect(css2).toContain('.global {');
|
|
227
|
-
expect(css2).not.toMatch(/\.global\.
|
|
227
|
+
expect(css2).not.toMatch(/\.global\.tsrx-[a-z0-9]+/);
|
|
228
228
|
});
|
|
229
229
|
});
|
|
@@ -24,7 +24,7 @@ describe('#style identifier', () => {
|
|
|
24
24
|
expect(div).toBeTruthy();
|
|
25
25
|
expect(div.textContent).toBe('styled child');
|
|
26
26
|
const classes = Array.from(div.classList);
|
|
27
|
-
expect(classes.some((cls: string) => cls.startsWith('
|
|
27
|
+
expect(classes.some((cls: string) => cls.startsWith('tsrx-'))).toBe(true);
|
|
28
28
|
expect(classes.some((cls: string) => cls === 'highlight')).toBe(true);
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -56,11 +56,11 @@ describe('#style identifier', () => {
|
|
|
56
56
|
expect(span).toBeTruthy();
|
|
57
57
|
|
|
58
58
|
const divClasses = Array.from(div.classList);
|
|
59
|
-
expect(divClasses.some((cls: string) => cls.startsWith('
|
|
59
|
+
expect(divClasses.some((cls: string) => cls.startsWith('tsrx-'))).toBe(true);
|
|
60
60
|
expect(divClasses.some((cls: string) => cls === 'primary')).toBe(true);
|
|
61
61
|
|
|
62
62
|
const spanClasses = Array.from(span.classList);
|
|
63
|
-
expect(spanClasses.some((cls: string) => cls.startsWith('
|
|
63
|
+
expect(spanClasses.some((cls: string) => cls.startsWith('tsrx-'))).toBe(true);
|
|
64
64
|
expect(spanClasses.some((cls: string) => cls === 'secondary')).toBe(true);
|
|
65
65
|
});
|
|
66
66
|
|
|
@@ -87,7 +87,7 @@ describe('#style identifier', () => {
|
|
|
87
87
|
const span = container.querySelector('span');
|
|
88
88
|
expect(span).toBeTruthy();
|
|
89
89
|
const classes = Array.from(span.classList);
|
|
90
|
-
expect(classes.some((cls: string) => cls.startsWith('
|
|
90
|
+
expect(classes.some((cls: string) => cls.startsWith('tsrx-'))).toBe(true);
|
|
91
91
|
expect(classes.some((cls: string) => cls === 'text')).toBe(true);
|
|
92
92
|
});
|
|
93
93
|
|
|
@@ -146,7 +146,7 @@ describe('#style identifier', () => {
|
|
|
146
146
|
const span = container.querySelector('span');
|
|
147
147
|
expect(span).toBeTruthy();
|
|
148
148
|
const classes = Array.from(span.classList);
|
|
149
|
-
expect(classes.some((cls: string) => cls.startsWith('
|
|
149
|
+
expect(classes.some((cls: string) => cls.startsWith('tsrx-'))).toBe(true);
|
|
150
150
|
expect(classes.some((cls: string) => cls === 'dual')).toBe(true);
|
|
151
151
|
});
|
|
152
152
|
});
|
|
@@ -365,7 +365,7 @@ export component App() {
|
|
|
365
365
|
const { js } = compile(source, 'test.tsrx');
|
|
366
366
|
|
|
367
367
|
expect(js.code).toContain('highlight');
|
|
368
|
-
expect(js.code).toMatch(/
|
|
368
|
+
expect(js.code).toMatch(/tsrx-[a-z0-9]+/);
|
|
369
369
|
});
|
|
370
370
|
|
|
371
371
|
it('generates #style object with standalone classes for server mode', () => {
|
|
@@ -385,7 +385,7 @@ export component App() {
|
|
|
385
385
|
const { js } = compile(source, 'test.tsrx', { mode: 'server' });
|
|
386
386
|
|
|
387
387
|
expect(js.code).toContain('highlight');
|
|
388
|
-
expect(js.code).toMatch(/
|
|
388
|
+
expect(js.code).toMatch(/tsrx-[a-z0-9]+/);
|
|
389
389
|
});
|
|
390
390
|
});
|
|
391
391
|
});
|
|
@@ -330,7 +330,7 @@ describe('dynamic DOM elements', () => {
|
|
|
330
330
|
|
|
331
331
|
// Check if scoped CSS class is present - THIS MIGHT FAIL if CSS pruning issue exists
|
|
332
332
|
const classes = Array.from(element.classList);
|
|
333
|
-
const hasScopedClass = classes.some((cls) => cls.startsWith('
|
|
333
|
+
const hasScopedClass = classes.some((cls) => cls.startsWith('tsrx-'));
|
|
334
334
|
expect(hasScopedClass).toBe(true);
|
|
335
335
|
});
|
|
336
336
|
|
|
@@ -375,7 +375,7 @@ describe('dynamic DOM elements', () => {
|
|
|
375
375
|
|
|
376
376
|
// Check if scoped CSS hash is applied to dynamic element
|
|
377
377
|
const classes = Array.from(button.classList);
|
|
378
|
-
const hasScopedClass = classes.some((cls) => cls.startsWith('
|
|
378
|
+
const hasScopedClass = classes.some((cls) => cls.startsWith('tsrx-'));
|
|
379
379
|
expect(hasScopedClass).toBe(true);
|
|
380
380
|
|
|
381
381
|
// Click to increment
|
|
@@ -390,7 +390,7 @@ describe('dynamic DOM elements', () => {
|
|
|
390
390
|
|
|
391
391
|
// Scoped CSS class should still be present
|
|
392
392
|
const newClasses = Array.from(button.classList);
|
|
393
|
-
const stillHasScopedClass = newClasses.some((cls) => cls.startsWith('
|
|
393
|
+
const stillHasScopedClass = newClasses.some((cls) => cls.startsWith('tsrx-'));
|
|
394
394
|
expect(stillHasScopedClass).toBe(true);
|
|
395
395
|
|
|
396
396
|
// Click again
|
|
@@ -446,7 +446,7 @@ describe('dynamic DOM elements', () => {
|
|
|
446
446
|
|
|
447
447
|
// Check if scoped CSS hash is applied (this is the critical test)
|
|
448
448
|
const classes = Array.from(button.classList);
|
|
449
|
-
const hasScopedClass = classes.some((cls) => cls.startsWith('
|
|
449
|
+
const hasScopedClass = classes.some((cls) => cls.startsWith('tsrx-'));
|
|
450
450
|
expect(hasScopedClass).toBe(true);
|
|
451
451
|
|
|
452
452
|
// Click to increment
|
|
@@ -460,7 +460,7 @@ describe('dynamic DOM elements', () => {
|
|
|
460
460
|
|
|
461
461
|
// Both classes should still be present
|
|
462
462
|
const newClasses = Array.from(button.classList);
|
|
463
|
-
const stillHasScopedClass = newClasses.some((cls) => cls.startsWith('
|
|
463
|
+
const stillHasScopedClass = newClasses.some((cls) => cls.startsWith('tsrx-'));
|
|
464
464
|
expect(stillHasScopedClass).toBe(true);
|
|
465
465
|
expect(newClasses.includes('even')).toBe(true);
|
|
466
466
|
});
|
|
@@ -484,8 +484,8 @@ describe('dynamic DOM elements', () => {
|
|
|
484
484
|
const div = container.querySelector('div');
|
|
485
485
|
const p = div.querySelector('p');
|
|
486
486
|
|
|
487
|
-
expect(Array.from(div.classList).some((c) => c.startsWith('
|
|
488
|
-
expect(Array.from(p.classList).some((c) => c.startsWith('
|
|
487
|
+
expect(Array.from(div.classList).some((c) => c.startsWith('tsrx-'))).toBe(true);
|
|
488
|
+
expect(Array.from(p.classList).some((c) => c.startsWith('tsrx-'))).toBe(true);
|
|
489
489
|
});
|
|
490
490
|
|
|
491
491
|
it('adds scoping class to dynamic elements when selector targets by tag name', () => {
|
|
@@ -507,8 +507,8 @@ describe('dynamic DOM elements', () => {
|
|
|
507
507
|
const div = container.querySelector('div');
|
|
508
508
|
const p = div.querySelector('p');
|
|
509
509
|
|
|
510
|
-
expect(Array.from(div.classList).some((c) => c.startsWith('
|
|
511
|
-
expect(Array.from(p.classList).some((c) => c.startsWith('
|
|
510
|
+
expect(Array.from(div.classList).some((c) => c.startsWith('tsrx-'))).toBe(true);
|
|
511
|
+
expect(Array.from(p.classList).some((c) => c.startsWith('tsrx-'))).toBe(true);
|
|
512
512
|
});
|
|
513
513
|
|
|
514
514
|
it('doesn\'t add scoping class to components inside dynamic element', () => {
|
|
@@ -544,9 +544,9 @@ describe('dynamic DOM elements', () => {
|
|
|
544
544
|
const innerDiv = outerDiv.querySelector('.child');
|
|
545
545
|
const innerP = innerDiv.querySelector('p');
|
|
546
546
|
|
|
547
|
-
const outerScope = Array.from(outerDiv.classList).find((c) => c.startsWith('
|
|
548
|
-
const innerScopes = Array.from(innerDiv.classList).filter((c) => c.startsWith('
|
|
549
|
-
const innerInnerScopes = Array.from(innerP.classList).filter((c) => c.startsWith('
|
|
547
|
+
const outerScope = Array.from(outerDiv.classList).find((c) => c.startsWith('tsrx-'));
|
|
548
|
+
const innerScopes = Array.from(innerDiv.classList).filter((c) => c.startsWith('tsrx-'));
|
|
549
|
+
const innerInnerScopes = Array.from(innerP.classList).filter((c) => c.startsWith('tsrx-'));
|
|
550
550
|
|
|
551
551
|
expect(outerScope).toBeTruthy();
|
|
552
552
|
|
|
@@ -585,8 +585,8 @@ describe('dynamic DOM elements', () => {
|
|
|
585
585
|
const div = container.querySelector('.child');
|
|
586
586
|
const p = div.querySelector('p');
|
|
587
587
|
|
|
588
|
-
const outerScopes = Array.from(div.classList).filter((c) => c.startsWith('
|
|
589
|
-
const innerScopes = Array.from(p.classList).filter((c) => c.startsWith('
|
|
588
|
+
const outerScopes = Array.from(div.classList).filter((c) => c.startsWith('tsrx-'));
|
|
589
|
+
const innerScopes = Array.from(p.classList).filter((c) => c.startsWith('tsrx-'));
|
|
590
590
|
|
|
591
591
|
expect(outerScopes).toHaveLength(1);
|
|
592
592
|
expect(innerScopes).toHaveLength(0);
|
|
@@ -35,9 +35,7 @@ describe('basic server > attribute rendering', () => {
|
|
|
35
35
|
|
|
36
36
|
const div = document.querySelector('div');
|
|
37
37
|
|
|
38
|
-
expect(Array.from(div.classList).some((className) => className.startsWith('
|
|
39
|
-
true,
|
|
40
|
-
);
|
|
38
|
+
expect(Array.from(div.classList).some((className) => className.startsWith('tsrx-'))).toBe(true);
|
|
41
39
|
expect(div.classList.contains('inactive')).toBe(true);
|
|
42
40
|
});
|
|
43
41
|
|
|
@@ -72,9 +70,7 @@ describe('basic server > attribute rendering', () => {
|
|
|
72
70
|
|
|
73
71
|
const div = document.querySelector('div');
|
|
74
72
|
|
|
75
|
-
expect(Array.from(div.classList).some((className) => className.startsWith('
|
|
76
|
-
true,
|
|
77
|
-
);
|
|
73
|
+
expect(Array.from(div.classList).some((className) => className.startsWith('tsrx-'))).toBe(true);
|
|
78
74
|
|
|
79
75
|
expect(div.classList.contains('foo')).toBe(true);
|
|
80
76
|
expect(div.classList.contains('bar')).toBe(true);
|
|
@@ -105,9 +101,7 @@ describe('basic server > attribute rendering', () => {
|
|
|
105
101
|
|
|
106
102
|
const div = document.querySelector('div');
|
|
107
103
|
|
|
108
|
-
expect(Array.from(div.classList).some((className) => className.startsWith('
|
|
109
|
-
true,
|
|
110
|
-
);
|
|
104
|
+
expect(Array.from(div.classList).some((className) => className.startsWith('tsrx-'))).toBe(true);
|
|
111
105
|
expect(div.classList.contains('inactive')).toBe(true);
|
|
112
106
|
expect(div.classList.contains('active')).toBe(false);
|
|
113
107
|
});
|
|
@@ -138,7 +132,7 @@ describe('basic server > attribute rendering', () => {
|
|
|
138
132
|
const divs = document.querySelectorAll('div');
|
|
139
133
|
|
|
140
134
|
divs.forEach((div) => {
|
|
141
|
-
expect(Array.from(div.classList).some((className) => className.startsWith('
|
|
135
|
+
expect(Array.from(div.classList).some((className) => className.startsWith('tsrx-'))).toBe(
|
|
142
136
|
true,
|
|
143
137
|
);
|
|
144
138
|
});
|
|
@@ -253,7 +253,7 @@ describe('server dynamic DOM elements', () => {
|
|
|
253
253
|
expect(element.classList.contains('test-class')).toBe(true);
|
|
254
254
|
|
|
255
255
|
const classes = Array.from(element.classList);
|
|
256
|
-
const hasScopedClass = classes.some((cls) => cls.startsWith('
|
|
256
|
+
const hasScopedClass = classes.some((cls) => cls.startsWith('tsrx-'));
|
|
257
257
|
expect(hasScopedClass).toBe(true);
|
|
258
258
|
});
|
|
259
259
|
|
|
@@ -292,7 +292,7 @@ describe('server dynamic DOM elements', () => {
|
|
|
292
292
|
|
|
293
293
|
// Check if scoped CSS hash is applied (this is the critical test)
|
|
294
294
|
const classes = Array.from(button.classList);
|
|
295
|
-
const hasScopedClass = classes.some((cls) => cls.startsWith('
|
|
295
|
+
const hasScopedClass = classes.some((cls) => cls.startsWith('tsrx-'));
|
|
296
296
|
expect(hasScopedClass).toBe(true);
|
|
297
297
|
});
|
|
298
298
|
|
|
@@ -317,8 +317,8 @@ describe('server dynamic DOM elements', () => {
|
|
|
317
317
|
const div = document.querySelector('div');
|
|
318
318
|
const p = div.querySelector('p');
|
|
319
319
|
|
|
320
|
-
expect(Array.from(div.classList).some((c) => c.startsWith('
|
|
321
|
-
expect(Array.from(p.classList).some((c) => c.startsWith('
|
|
320
|
+
expect(Array.from(div.classList).some((c) => c.startsWith('tsrx-'))).toBe(true);
|
|
321
|
+
expect(Array.from(p.classList).some((c) => c.startsWith('tsrx-'))).toBe(true);
|
|
322
322
|
});
|
|
323
323
|
|
|
324
324
|
it(
|
|
@@ -346,8 +346,8 @@ describe('server dynamic DOM elements', () => {
|
|
|
346
346
|
const div = document.querySelector('div');
|
|
347
347
|
const p = div.querySelector('p');
|
|
348
348
|
|
|
349
|
-
expect(Array.from(div.classList).some((c) => c.startsWith('
|
|
350
|
-
expect(Array.from(p.classList).some((c) => c.startsWith('
|
|
349
|
+
expect(Array.from(div.classList).some((c) => c.startsWith('tsrx-'))).toBe(true);
|
|
350
|
+
expect(Array.from(p.classList).some((c) => c.startsWith('tsrx-'))).toBe(true);
|
|
351
351
|
},
|
|
352
352
|
);
|
|
353
353
|
|
|
@@ -386,9 +386,9 @@ describe('server dynamic DOM elements', () => {
|
|
|
386
386
|
const innerDiv = outerDiv.querySelector('.child');
|
|
387
387
|
const innerP = innerDiv.querySelector('p');
|
|
388
388
|
|
|
389
|
-
const outerScope = Array.from(outerDiv.classList).find((c) => c.startsWith('
|
|
390
|
-
const innerScopes = Array.from(innerDiv.classList).filter((c) => c.startsWith('
|
|
391
|
-
const innerInnerScopes = Array.from(innerP.classList).filter((c) => c.startsWith('
|
|
389
|
+
const outerScope = Array.from(outerDiv.classList).find((c) => c.startsWith('tsrx-'));
|
|
390
|
+
const innerScopes = Array.from(innerDiv.classList).filter((c) => c.startsWith('tsrx-'));
|
|
391
|
+
const innerInnerScopes = Array.from(innerP.classList).filter((c) => c.startsWith('tsrx-'));
|
|
392
392
|
|
|
393
393
|
expect(outerScope).toBeTruthy();
|
|
394
394
|
|
|
@@ -429,8 +429,8 @@ describe('server dynamic DOM elements', () => {
|
|
|
429
429
|
const div = document.querySelector('.child');
|
|
430
430
|
const p = div.querySelector('p');
|
|
431
431
|
|
|
432
|
-
const outerScopes = Array.from(div.classList).filter((c) => c.startsWith('
|
|
433
|
-
const innerScopes = Array.from(p.classList).filter((c) => c.startsWith('
|
|
432
|
+
const outerScopes = Array.from(div.classList).filter((c) => c.startsWith('tsrx-'));
|
|
433
|
+
const innerScopes = Array.from(p.classList).filter((c) => c.startsWith('tsrx-'));
|
|
434
434
|
|
|
435
435
|
expect(outerScopes).toHaveLength(1);
|
|
436
436
|
expect(innerScopes).toHaveLength(0);
|
|
@@ -25,7 +25,7 @@ describe('#style identifier (server)', () => {
|
|
|
25
25
|
expect(div).toBeTruthy();
|
|
26
26
|
expect(div.textContent).toBe('styled child');
|
|
27
27
|
const classes = Array.from(div.classList);
|
|
28
|
-
expect(classes.some((cls: string) => cls.startsWith('
|
|
28
|
+
expect(classes.some((cls: string) => cls.startsWith('tsrx-'))).toBe(true);
|
|
29
29
|
expect(classes.some((cls: string) => cls === 'highlight')).toBe(true);
|
|
30
30
|
});
|
|
31
31
|
|
|
@@ -58,11 +58,11 @@ describe('#style identifier (server)', () => {
|
|
|
58
58
|
expect(span).toBeTruthy();
|
|
59
59
|
|
|
60
60
|
const divClasses = Array.from(div.classList);
|
|
61
|
-
expect(divClasses.some((cls: string) => cls.startsWith('
|
|
61
|
+
expect(divClasses.some((cls: string) => cls.startsWith('tsrx-'))).toBe(true);
|
|
62
62
|
expect(divClasses.some((cls: string) => cls === 'primary')).toBe(true);
|
|
63
63
|
|
|
64
64
|
const spanClasses = Array.from(span.classList);
|
|
65
|
-
expect(spanClasses.some((cls: string) => cls.startsWith('
|
|
65
|
+
expect(spanClasses.some((cls: string) => cls.startsWith('tsrx-'))).toBe(true);
|
|
66
66
|
expect(spanClasses.some((cls: string) => cls === 'secondary')).toBe(true);
|
|
67
67
|
});
|
|
68
68
|
});
|
|
@@ -89,7 +89,7 @@ describe('#style identifier (server)', () => {
|
|
|
89
89
|
const button = document.querySelector('button');
|
|
90
90
|
expect(button).toBeTruthy();
|
|
91
91
|
const classes = Array.from(button.classList);
|
|
92
|
-
expect(classes.some((cls: string) => cls.startsWith('
|
|
92
|
+
expect(classes.some((cls: string) => cls.startsWith('tsrx-'))).toBe(true);
|
|
93
93
|
expect(classes.some((cls: string) => cls === 'fancy')).toBe(true);
|
|
94
94
|
});
|
|
95
95
|
|
|
@@ -152,7 +152,7 @@ describe('#style identifier (server)', () => {
|
|
|
152
152
|
const span = document.querySelector('span');
|
|
153
153
|
expect(span).toBeTruthy();
|
|
154
154
|
const classes = Array.from(span.classList);
|
|
155
|
-
expect(classes.some((cls: string) => cls.startsWith('
|
|
155
|
+
expect(classes.some((cls: string) => cls.startsWith('tsrx-'))).toBe(true);
|
|
156
156
|
expect(classes.some((cls: string) => cls === 'dual')).toBe(true);
|
|
157
157
|
},
|
|
158
158
|
);
|
|
@@ -182,7 +182,7 @@ describe('#style identifier (server)', () => {
|
|
|
182
182
|
const span = document.querySelector('span');
|
|
183
183
|
expect(span).toBeTruthy();
|
|
184
184
|
const classes = Array.from(span.classList);
|
|
185
|
-
expect(classes.some((cls: string) => cls.startsWith('
|
|
185
|
+
expect(classes.some((cls: string) => cls.startsWith('tsrx-'))).toBe(true);
|
|
186
186
|
expect(classes.some((cls: string) => cls === 'text')).toBe(true);
|
|
187
187
|
});
|
|
188
188
|
|
|
@@ -220,10 +220,8 @@ describe('#style identifier (server)', () => {
|
|
|
220
220
|
const { document } = parseHtml(body);
|
|
221
221
|
const wrapper = document.querySelector('.green');
|
|
222
222
|
const child = document.querySelector('.red');
|
|
223
|
-
const wrapper_scopes = Array.from(wrapper.classList).filter(
|
|
224
|
-
|
|
225
|
-
);
|
|
226
|
-
const child_scopes = Array.from(child.classList).filter((name) => name.startsWith('ripple-'));
|
|
223
|
+
const wrapper_scopes = Array.from(wrapper.classList).filter((name) => name.startsWith('tsrx-'));
|
|
224
|
+
const child_scopes = Array.from(child.classList).filter((name) => name.startsWith('tsrx-'));
|
|
227
225
|
|
|
228
226
|
expect(wrapper_scopes).toHaveLength(1);
|
|
229
227
|
expect(child_scopes).toHaveLength(1);
|
|
@@ -256,7 +254,7 @@ describe('#style identifier (server)', () => {
|
|
|
256
254
|
const { document } = parseHtml(body);
|
|
257
255
|
const slotted_child = document.querySelector('section > div.green');
|
|
258
256
|
const slotted_scopes = Array.from(slotted_child.classList).filter(
|
|
259
|
-
(name) => name.startsWith('
|
|
257
|
+
(name) => name.startsWith('tsrx-'),
|
|
260
258
|
);
|
|
261
259
|
|
|
262
260
|
expect(slotted_scopes).toHaveLength(1);
|
|
@@ -280,7 +278,7 @@ export component App() {
|
|
|
280
278
|
const { js } = compile(source, 'test.tsrx', { mode: 'server' });
|
|
281
279
|
|
|
282
280
|
expect(js.code).toContain('highlight');
|
|
283
|
-
expect(js.code).toMatch(/
|
|
281
|
+
expect(js.code).toMatch(/tsrx-[a-z0-9]+/);
|
|
284
282
|
expect(js.code).toContain('register_css');
|
|
285
283
|
});
|
|
286
284
|
|
|
@@ -303,9 +301,9 @@ export component App() {
|
|
|
303
301
|
|
|
304
302
|
expect(css.size).toBeGreaterThan(0);
|
|
305
303
|
const hashes = Array.from(css);
|
|
306
|
-
expect(hashes.some((h: string) => h.startsWith('
|
|
304
|
+
expect(hashes.some((h: string) => h.startsWith('tsrx-'))).toBe(true);
|
|
307
305
|
|
|
308
|
-
expect(body).toMatch(/
|
|
306
|
+
expect(body).toMatch(/tsrx-[a-z0-9]+/);
|
|
309
307
|
expect(body).toContain('styled');
|
|
310
308
|
});
|
|
311
309
|
});
|