Skip to content

Commit cf846a5

Browse files
Ensure nested selectors are not modified when using group-* and peer-*
Co-authored-by: Robin Malfait <[email protected]>
1 parent 23e6d43 commit cf846a5

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

packages/tailwindcss/src/index.test.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,4 +1811,53 @@ describe('@variant', () => {
18111811
}"
18121812
`)
18131813
})
1814+
1815+
test('combining multiple complex variants', () => {
1816+
let compiled = compile(css`
1817+
@variant one {
1818+
&.foo-1 {
1819+
&.bar-1 {
1820+
@slot;
1821+
}
1822+
}
1823+
}
1824+
1825+
@variant two {
1826+
&.foo-2 {
1827+
&.bar-2 {
1828+
@slot;
1829+
}
1830+
}
1831+
}
1832+
1833+
@layer utilities {
1834+
@tailwind utilities;
1835+
}
1836+
`).build([
1837+
'group-one:two:underline',
1838+
'one:group-two:underline',
1839+
'peer-one:two:underline',
1840+
'one:peer-two:underline',
1841+
])
1842+
1843+
expect(optimizeCss(compiled).trim()).toMatchInlineSnapshot(`
1844+
"@layer utilities {
1845+
.one\\:group-two\\:underline.foo-1.bar-1:is(:where(.group).foo-2 *):is(:where(.group).bar-2 *) {
1846+
text-decoration-line: underline;
1847+
}
1848+
1849+
.one\\:peer-two\\:underline.foo-1.bar-1:is(:where(.peer).foo-2 ~ *):is(:where(.peer).bar-2 ~ *) {
1850+
text-decoration-line: underline;
1851+
}
1852+
1853+
.group-one\\:two\\:underline:is(:where(.group).foo-1 *):is(:where(.group).bar-1 *).foo-2.bar-2 {
1854+
text-decoration-line: underline;
1855+
}
1856+
1857+
.peer-one\\:two\\:underline:is(:where(.peer).foo-1 ~ *):is(:where(.peer).bar-1 ~ *).foo-2.bar-2 {
1858+
text-decoration-line: underline;
1859+
}
1860+
}"
1861+
`)
1862+
})
18141863
})

0 commit comments

Comments
 (0)