Skip to content

Commit 8b1c965

Browse files
authored
Fix psuedo element validator by updating css-what (#1106)
1 parent 48df15c commit 8b1c965

File tree

4 files changed

+83
-41
lines changed

4 files changed

+83
-41
lines changed

.changeset/loud-zoos-allow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@vanilla-extract/css': patch
3+
---
4+
5+
Fix "Invalid selector" errors on pseudo-elements with params

packages/css/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"@vanilla-extract/private": "^1.0.3",
112112
"ahocorasick": "1.0.2",
113113
"chalk": "^4.1.1",
114-
"css-what": "^5.0.1",
114+
"css-what": "^6.1.0",
115115
"cssesc": "^3.0.0",
116116
"csstype": "^3.0.7",
117117
"deep-object-diff": "^1.1.9",

packages/css/src/transformCss.test.ts

Lines changed: 69 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,44 +2154,76 @@ describe('transformCss', () => {
21542154
}
21552155
`);
21562156
});
2157-
});
21582157

2159-
it('should handle multiple references to the same locally scoped selector', () => {
2160-
expect(
2161-
transformCss({
2162-
composedClassLists: [],
2163-
localClassNames: [style1, style2, '_1g1ptzo1', '_1g1ptzo10'],
2164-
cssObjs: [
2165-
{
2166-
type: 'local',
2167-
selector: style1,
2168-
rule: {
2169-
selectors: {
2170-
[`${style2} &:before, ${style2} &:after`]: {
2171-
background: 'black',
2172-
},
2173-
[`_1g1ptzo1_1g1ptzo10 ${style1}`]: {
2174-
background: 'blue',
2175-
},
2176-
[`_1g1ptzo10_1g1ptzo1 ${style1}`]: {
2177-
background: 'blue',
2178-
},
2179-
},
2180-
},
2181-
},
2182-
],
2183-
}).join('\n'),
2184-
).toMatchInlineSnapshot(`
2185-
.skkcyc2 .skkcyc1:before, .skkcyc2 .skkcyc1:after {
2186-
background: black;
2187-
}
2188-
._1g1ptzo1._1g1ptzo10 .skkcyc1 {
2189-
background: blue;
2190-
}
2191-
._1g1ptzo10._1g1ptzo1 .skkcyc1 {
2192-
background: blue;
2193-
}
2194-
`);
2158+
it('should handle the pseudo-elements with params', () => {
2159+
expect(
2160+
transformCss({
2161+
composedClassLists: [],
2162+
localClassNames: ['testClass'],
2163+
cssObjs: [
2164+
{
2165+
type: 'local',
2166+
selector: 'testClass',
2167+
rule: {
2168+
selectors: {
2169+
'&::part(external-wrapper)': {
2170+
display: 'block',
2171+
},
2172+
'&::slotted(span)': {
2173+
display: 'block',
2174+
},
2175+
},
2176+
},
2177+
},
2178+
],
2179+
}).join('\n'),
2180+
).toMatchInlineSnapshot(`
2181+
.testClass::part(external-wrapper) {
2182+
display: block;
2183+
}
2184+
.testClass::slotted(span) {
2185+
display: block;
2186+
}
2187+
`);
2188+
});
2189+
2190+
it('should handle multiple references to the same locally scoped selector', () => {
2191+
expect(
2192+
transformCss({
2193+
composedClassLists: [],
2194+
localClassNames: [style1, style2, '_1g1ptzo1', '_1g1ptzo10'],
2195+
cssObjs: [
2196+
{
2197+
type: 'local',
2198+
selector: style1,
2199+
rule: {
2200+
selectors: {
2201+
[`${style2} &:before, ${style2} &:after`]: {
2202+
background: 'black',
2203+
},
2204+
[`_1g1ptzo1_1g1ptzo10 ${style1}`]: {
2205+
background: 'blue',
2206+
},
2207+
[`_1g1ptzo10_1g1ptzo1 ${style1}`]: {
2208+
background: 'blue',
2209+
},
2210+
},
2211+
},
2212+
},
2213+
],
2214+
}).join('\n'),
2215+
).toMatchInlineSnapshot(`
2216+
.skkcyc2 .skkcyc1:before, .skkcyc2 .skkcyc1:after {
2217+
background: black;
2218+
}
2219+
._1g1ptzo1._1g1ptzo10 .skkcyc1 {
2220+
background: blue;
2221+
}
2222+
._1g1ptzo10._1g1ptzo1 .skkcyc1 {
2223+
background: blue;
2224+
}
2225+
`);
2226+
});
21952227
});
21962228

21972229
endFileScope();

pnpm-lock.yaml

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)