mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Support applying important utilities in JIT (#4260)
This commit is contained in:
parent
8e49526e6f
commit
114baeeef1
@ -30,7 +30,6 @@ function buildApplyCache(applyCandidates, context) {
|
||||
return context.applyClassCache
|
||||
}
|
||||
|
||||
// TODO: Apply `!important` stuff correctly instead of just skipping it
|
||||
function extractApplyCandidates(params) {
|
||||
let candidates = params.split(/[\s\t\n]+/g)
|
||||
|
||||
@ -143,7 +142,6 @@ function processApply(root, context) {
|
||||
.join(', ')
|
||||
}
|
||||
|
||||
/** @type {Map<import('postcss').Node, [string, boolean, import('postcss').Node[]][]>} */
|
||||
let perParentApplies = new Map()
|
||||
|
||||
// Collect all apply candidates and their rules
|
||||
@ -197,7 +195,7 @@ function processApply(root, context) {
|
||||
rule.selector = replaceSelector(parent.selector, rule.selector, applyCandidate)
|
||||
|
||||
rule.walkDecls((d) => {
|
||||
d.important = important
|
||||
d.important = meta.important || important
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ function applyImportant(matches) {
|
||||
})
|
||||
r.walkDecls((d) => (d.important = true))
|
||||
})
|
||||
result.push([meta, container.nodes[0]])
|
||||
result.push([{ ...meta, important: true }, container.nodes[0]])
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
@ -323,6 +323,11 @@ h2 {
|
||||
line-height: 2rem;
|
||||
}
|
||||
}
|
||||
.important-modifier {
|
||||
border-radius: 0.375rem !important;
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
<div class="recursive-apply-c"></div>
|
||||
<div class="use-with-other-properties-base use-with-other-properties-component"></div>
|
||||
<div class="add-sibling-properties"></div>
|
||||
<div class="important-modifier"></div>
|
||||
<div class="a b"></div>
|
||||
<div class="foo"></div>
|
||||
<div class="bar"></div>
|
||||
|
||||
@ -119,6 +119,10 @@ test('@apply', () => {
|
||||
@apply lg:text-2xl;
|
||||
@apply sm:text-2xl;
|
||||
}
|
||||
|
||||
.important-modifier {
|
||||
@apply px-4 !rounded-md;
|
||||
}
|
||||
}
|
||||
|
||||
@layer utilities {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user