Skip to content

Commit b8c3123

Browse files
thecrypticaceKrisBraun
authored andcommitted
Sort arbitrary properties alphabetically across multiple class lists (#12911)
* Sort arbitrary properties alphabetically across multiple files * Update test
1 parent 89f0f54 commit b8c3123

File tree

1 file changed

+51
-177
lines changed

1 file changed

+51
-177
lines changed

tests/variants.test.js

+51-177
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,57 @@ import { crosscheck, run, html, css, defaults } from './util/run'
55

66
crosscheck(({ stable, oxide }) => {
77
test('variants', () => {
8+
let config = {
9+
darkMode: 'selector',
10+
content: [path.resolve(__dirname, './variants.test.html')],
11+
corePlugins: { preflight: false },
12+
}
13+
14+
let input = css`
15+
@tailwind base;
16+
@tailwind components;
17+
@tailwind utilities;
18+
`
19+
20+
return run(input, config).then((result) => {
21+
expect(result.css).toMatchFormattedCss(
22+
fs.readFileSync(path.resolve(__dirname, './variants.test.css'), 'utf8')
23+
)
24+
})
25+
})
26+
27+
test('order matters and produces different behaviour', () => {
28+
let config = {
29+
content: [
30+
{
31+
raw: html`
32+
<div class="hover:file:[--value:1]"></div>
33+
<div class="file:hover:[--value:2]"></div>
34+
`,
35+
},
36+
],
37+
}
38+
39+
return run('@tailwind utilities', config).then((result) => {
40+
expect(result.css).toMatchFormattedCss(css`
41+
.hover\:file\:\[--value\:1\]::-webkit-file-upload-button:hover {
42+
--value: 1;
43+
}
44+
.hover\:file\:\[--value\:1\]::file-selector-button:hover {
45+
--value: 1;
46+
}
47+
.file\:hover\:\[--value\:2\]:hover::-webkit-file-upload-button {
48+
--value: 2;
49+
}
50+
.file\:hover\:\[--value\:2\]:hover::file-selector-button {
51+
--value: 2;
52+
}
53+
`)
54+
})
55+
})
56+
57+
describe('custom advanced variants', () => {
58+
test('at-rules without params', () => {
859
let config = {
960
darkMode: 'selector',
1061
content: [path.resolve(__dirname, './variants.test.html')],
@@ -1070,181 +1121,4 @@ crosscheck(({ stable, oxide }) => {
10701121
`)
10711122
})
10721123
})
1073-
1074-
test('variants with slashes support modifiers', () => {
1075-
let config = {
1076-
content: [
1077-
{
1078-
raw: html` <div class="ar-1/10/20:text-red-500">ar-1/10</div> `,
1079-
},
1080-
],
1081-
corePlugins: { preflight: false },
1082-
plugins: [
1083-
function ({ matchVariant }) {
1084-
matchVariant(
1085-
'ar',
1086-
(value, { modifier }) => {
1087-
return [`@media (min-aspect-ratio: ${value}) and (foo: ${modifier})`]
1088-
},
1089-
{ values: { '1/10': '1/10' } }
1090-
)
1091-
},
1092-
],
1093-
}
1094-
1095-
let input = css`
1096-
@tailwind utilities;
1097-
`
1098-
1099-
return run(input, config).then((result) => {
1100-
stable.expect(result.css).toMatchFormattedCss(css`
1101-
@media (min-aspect-ratio: 1 / 10) and (foo: 20) {
1102-
.ar-1\/10\/20\:text-red-500 {
1103-
--tw-text-opacity: 1;
1104-
color: rgb(239 68 68 / var(--tw-text-opacity));
1105-
}
1106-
}
1107-
`)
1108-
oxide.expect(result.css).toMatchFormattedCss(css`
1109-
@media (min-aspect-ratio: 1 / 10) and (foo: 20) {
1110-
.ar-1\/10\/20\:text-red-500 {
1111-
color: #ef4444;
1112-
}
1113-
}
1114-
`)
1115-
})
1116-
})
1117-
1118-
test('arbitrary variant selectors should not re-order scrollbar pseudo classes', async () => {
1119-
let config = {
1120-
content: [
1121-
{
1122-
raw: html`
1123-
<div class="[&::-webkit-scrollbar:hover]:underline" />
1124-
<div class="[&::-webkit-scrollbar-button:hover]:underline" />
1125-
<div class="[&::-webkit-scrollbar-thumb:hover]:underline" />
1126-
<div class="[&::-webkit-scrollbar-track:hover]:underline" />
1127-
<div class="[&::-webkit-scrollbar-track-piece:hover]:underline" />
1128-
<div class="[&::-webkit-scrollbar-corner:hover]:underline" />
1129-
<div class="[&::-webkit-resizer:hover]:underline" />
1130-
`,
1131-
},
1132-
],
1133-
corePlugins: { preflight: false },
1134-
}
1135-
1136-
let input = css`
1137-
@tailwind utilities;
1138-
`
1139-
1140-
let result = await run(input, config)
1141-
1142-
expect(result.css).toMatchFormattedCss(css`
1143-
.\[\&\:\:-webkit-resizer\:hover\]\:underline::-webkit-resizer:hover {
1144-
text-decoration-line: underline;
1145-
}
1146-
.\[\&\:\:-webkit-scrollbar-button\:hover\]\:underline::-webkit-scrollbar-button:hover {
1147-
text-decoration-line: underline;
1148-
}
1149-
.\[\&\:\:-webkit-scrollbar-corner\:hover\]\:underline::-webkit-scrollbar-corner:hover {
1150-
text-decoration-line: underline;
1151-
}
1152-
.\[\&\:\:-webkit-scrollbar-thumb\:hover\]\:underline::-webkit-scrollbar-thumb:hover {
1153-
text-decoration-line: underline;
1154-
}
1155-
.\[\&\:\:-webkit-scrollbar-track-piece\:hover\]\:underline::-webkit-scrollbar-track-piece:hover {
1156-
text-decoration-line: underline;
1157-
}
1158-
.\[\&\:\:-webkit-scrollbar-track\:hover\]\:underline::-webkit-scrollbar-track:hover {
1159-
text-decoration-line: underline;
1160-
}
1161-
.\[\&\:\:-webkit-scrollbar\:hover\]\:underline::-webkit-scrollbar:hover {
1162-
text-decoration-line: underline;
1163-
}
1164-
`)
1165-
})
1166-
1167-
test('stacking dark and rtl variants', async () => {
1168-
let config = {
1169-
darkMode: 'selector',
1170-
content: [
1171-
{
1172-
raw: html`<div class="dark:rtl:italic" />`,
1173-
},
1174-
],
1175-
corePlugins: { preflight: false },
1176-
}
1177-
1178-
let input = css`
1179-
@tailwind utilities;
1180-
`
1181-
1182-
let result = await run(input, config)
1183-
1184-
expect(result.css).toMatchFormattedCss(css`
1185-
.dark\:rtl\:italic:where([dir='rtl'], [dir='rtl'] *):where(.dark, .dark *) {
1186-
font-style: italic;
1187-
}
1188-
`)
1189-
})
1190-
1191-
test('stacking dark and rtl variants with pseudo elements', async () => {
1192-
let config = {
1193-
darkMode: 'selector',
1194-
content: [
1195-
{
1196-
raw: html`<div class="dark:rtl:placeholder:italic" />`,
1197-
},
1198-
],
1199-
corePlugins: { preflight: false },
1200-
}
1201-
1202-
let input = css`
1203-
@tailwind utilities;
1204-
`
1205-
1206-
let result = await run(input, config)
1207-
1208-
expect(result.css).toMatchFormattedCss(css`
1209-
.dark\:rtl\:placeholder\:italic:where([dir='rtl'], [dir='rtl'] *):where(
1210-
.dark,
1211-
.dark *
1212-
)::placeholder {
1213-
font-style: italic;
1214-
}
1215-
`)
1216-
})
1217-
1218-
test('* is matched by the parser as the children variant', async () => {
1219-
let config = {
1220-
content: [
1221-
{
1222-
raw: html`
1223-
<div class="*:italic" />
1224-
<div class="*:hover:italic" />
1225-
<div class="hover:*:italic" />
1226-
<div class="data-[slot=label]:*:hover:italic" />
1227-
<div class="[&_p]:*:hover:italic" />
1228-
`,
1229-
},
1230-
],
1231-
corePlugins: { preflight: false },
1232-
}
1233-
1234-
let input = css`
1235-
@tailwind utilities;
1236-
`
1237-
1238-
let result = await run(input, config)
1239-
1240-
expect(result.css).toMatchFormattedCss(css`
1241-
.\*\:italic > *,
1242-
.\*\:hover\:italic:hover > *,
1243-
.hover\:\*\:italic > :hover,
1244-
.data-\[slot\=label\]\:\*\:hover\:italic:hover > [data-slot='label'],
1245-
.\[\&_p\]\:\*\:hover\:italic:hover > * p {
1246-
font-style: italic;
1247-
}
1248-
`)
1249-
})
12501124
})

0 commit comments

Comments
 (0)