* exclude `Features.LogicalProperties` lightningcss feature We don't want this to automatically apply since we have dedicated logical property based utilities already. We also have a feature flag to toggle some utilities to make use of logical property based ones. This feature should be opt-in to prevent backwards compatibility (e.g.: RTL sites that _did_ use a mr-4 explicitly). * update default browserslist * explicitly include/exclude Lightning CSS features * update tests based on new browserslist and include/exclude features from Lightning CSS * update integration tests * prefer user browserslist, fallback to built-in browserslist * always include Nesting If a custom browserslist config is used, then we don't explicitly set the include/exclude features from Lightning CSS (except for nesting, we always want to process nesting) * ensure to fallback to the current working directory * update changelog
93 lines
2.4 KiB
JavaScript
93 lines
2.4 KiB
JavaScript
import selectorParser from 'postcss-selector-parser'
|
|
|
|
import { run, html, css } from './util/run'
|
|
|
|
test('modify selectors', () => {
|
|
let config = {
|
|
darkMode: 'class',
|
|
content: [
|
|
{
|
|
raw: html`
|
|
<div class="font-bold"></div>
|
|
<div class="foo:font-bold"></div>
|
|
<div class="foo:hover:font-bold"></div>
|
|
<div class="sm:foo:font-bold"></div>
|
|
<div class="md:foo:focus:font-bold"></div>
|
|
<div class="markdown">
|
|
<p>Lorem ipsum dolor sit amet...</p>
|
|
</div>
|
|
<div class="foo:markdown">
|
|
<p>Lorem ipsum dolor sit amet...</p>
|
|
</div>
|
|
<div class="foo:visited:markdown">
|
|
<p>Lorem ipsum dolor sit amet...</p>
|
|
</div>
|
|
<div class="lg:foo:disabled:markdown">
|
|
<p>Lorem ipsum dolor sit amet...</p>
|
|
</div>
|
|
`,
|
|
},
|
|
],
|
|
corePlugins: { preflight: false },
|
|
theme: {},
|
|
plugins: [
|
|
function ({ addVariant }) {
|
|
addVariant('foo', ({ modifySelectors, separator }) => {
|
|
modifySelectors(({ selector }) => {
|
|
return selectorParser((selectors) => {
|
|
selectors.walkClasses((classNode) => {
|
|
classNode.value = `foo${separator}${classNode.value}`
|
|
classNode.parent.insertBefore(classNode, selectorParser().astSync(`.foo `))
|
|
})
|
|
}).processSync(selector)
|
|
})
|
|
})
|
|
},
|
|
],
|
|
}
|
|
|
|
let input = css`
|
|
@tailwind components;
|
|
@tailwind utilities;
|
|
|
|
@layer components {
|
|
.markdown > p {
|
|
margin-top: 12px;
|
|
}
|
|
}
|
|
`
|
|
|
|
return run(input, config).then((result) => {
|
|
expect(result.css).toMatchFormattedCss(css`
|
|
.markdown > p {
|
|
margin-top: 12px;
|
|
}
|
|
.font-bold {
|
|
font-weight: 700;
|
|
}
|
|
.foo .foo\:markdown > p,
|
|
.foo .foo\:visited\:markdown:visited > p {
|
|
margin-top: 12px;
|
|
}
|
|
@media (min-width: 1024px) {
|
|
.foo .lg\:foo\:disabled\:markdown:disabled > p {
|
|
margin-top: 12px;
|
|
}
|
|
}
|
|
.foo .foo\:font-bold,
|
|
.foo .foo\:hover\:font-bold:hover {
|
|
font-weight: 700;
|
|
}
|
|
@media (min-width: 640px) {
|
|
.foo .sm\:foo\:font-bold {
|
|
font-weight: 700;
|
|
}
|
|
}
|
|
@media (min-width: 768px) {
|
|
.foo .md\:foo\:focus\:font-bold:focus {
|
|
font-weight: 700;
|
|
}
|
|
}
|
|
`)
|
|
})
|
|
})
|