Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit 86d7ab3

Browse files
committed
Skip !important in apply for now
1 parent ed84fe4 commit 86d7ab3

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/lib/expandApplyAtRules.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,27 @@ function buildApplyCache(applyCandidates, context) {
2727
return context.applyClassCache
2828
}
2929

30+
// TODO: Apply `!important` stuff correctly instead of just skipping it
31+
function extractApplyCandidates(params) {
32+
let candidates = params.split(/[\s\t\n]+/g)
33+
34+
if (candidates[candidates.length - 1] === '!important') {
35+
candidates = candidates.slice(0, -1)
36+
}
37+
38+
return candidates
39+
}
40+
3041
function expandApplyAtRules(context) {
3142
return (root) => {
3243
let applyCandidates = new Set()
3344

3445
// Collect all @apply rules and candidates
3546
let applies = []
3647
root.walkAtRules('apply', (rule) => {
37-
for (let util of rule.params.split(/[\s\t\n]+/g)) {
48+
let candidates = extractApplyCandidates(rule.params)
49+
50+
for (let util of candidates) {
3851
applyCandidates.add(util)
3952
}
4053
applies.push(rule)
@@ -75,7 +88,8 @@ function expandApplyAtRules(context) {
7588

7689
for (let apply of applies) {
7790
let siblings = []
78-
let applyCandidates = apply.params.split(/[\s\t\n]+/g)
91+
let applyCandidates = extractApplyCandidates(apply.params)
92+
7993
for (let applyCandidate of applyCandidates) {
8094
if (!applyClassCache.has(applyCandidate)) {
8195
throw new Error(

0 commit comments

Comments
 (0)