Skip to content

Commit 9d257a9

Browse files
committed
Rename inject instances to apply
1 parent e37b665 commit 9d257a9

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/flagged/applyComplexClasses.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function hasAtRule(css, atRule) {
2020
return foundAtRule
2121
}
2222

23-
function applyUtility({ rule, utilityName: className, classPosition }, replaceWith) {
23+
function generateRulesFromApply({ rule, utilityName: className, classPosition }, replaceWith) {
2424
const processedSelectors = rule.selectors.map(selector => {
2525
const processor = selectorParser(selectors => {
2626
let i = 0
@@ -172,43 +172,43 @@ function processApplyAtRules(css, lookupTree, config) {
172172

173173
while (hasAtRule(css, 'apply')) {
174174
css.walkRules(rule => {
175-
const injectRules = []
175+
const applyRules = []
176176

177177
// Only walk direct children to avoid issues with nesting plugins
178178
rule.each(child => {
179179
if (child.type === 'atrule' && child.name === 'apply') {
180-
injectRules.unshift(child)
180+
applyRules.unshift(child)
181181
}
182182
})
183183

184-
injectRules.forEach(inject => {
184+
applyRules.forEach(applyRule => {
185185
const [
186186
importantEntries,
187-
injectUtilityNames,
187+
applyUtilityNames,
188188
important = importantEntries.length > 0,
189-
] = _.partition(inject.params.split(' '), n => n === '!important')
189+
] = _.partition(applyRule.params.split(' '), n => n === '!important')
190190

191191
const currentUtilityNames = extractUtilityNames(rule.selector)
192192

193-
if (_.intersection(injectUtilityNames, currentUtilityNames).length > 0) {
194-
const currentUtilityName = _.intersection(injectUtilityNames, currentUtilityNames)[0]
193+
if (_.intersection(applyUtilityNames, currentUtilityNames).length > 0) {
194+
const currentUtilityName = _.intersection(applyUtilityNames, currentUtilityNames)[0]
195195
throw rule.error(
196196
`You cannot \`@apply\` the \`${currentUtilityName}\` utility here because it creates a circular dependency.`
197197
)
198198
}
199199

200-
// Extract any post-inject declarations and re-insert them after inject rules
200+
// Extract any post-apply declarations and re-insert them after apply rules
201201
const afterRule = rule.clone({ raws: {} })
202-
afterRule.nodes = afterRule.nodes.slice(rule.index(inject) + 1)
203-
rule.nodes = rule.nodes.slice(0, rule.index(inject) + 1)
202+
afterRule.nodes = afterRule.nodes.slice(rule.index(applyRule) + 1)
203+
rule.nodes = rule.nodes.slice(0, rule.index(applyRule) + 1)
204204

205-
// Sort injects to match CSS source order
206-
const injects = extractUtilityRules(injectUtilityNames, inject)
205+
// Sort applys to match CSS source order
206+
const applys = extractUtilityRules(applyUtilityNames, applyRule)
207207

208208
// Get new rules with the utility portion of the selector replaced with the new selector
209209
const rulesToInsert = [
210-
...injects.map(injectUtility => {
211-
return applyUtility(injectUtility, rule.selector)
210+
...applys.map(applyUtility => {
211+
return generateRulesFromApply(applyUtility, rule.selector)
212212
}),
213213
afterRule,
214214
]
@@ -219,11 +219,11 @@ function processApplyAtRules(css, lookupTree, config) {
219219

220220
const mergedRules = mergeAdjacentRules(rule, nodes)
221221

222-
inject.remove()
222+
applyRule.remove()
223223
rule.after(mergedRules)
224224
})
225225

226-
// If the base rule has nothing in it (all injects were pseudo or responsive variants),
226+
// If the base rule has nothing in it (all applys were pseudo or responsive variants),
227227
// remove the rule fuggit.
228228
if (rule.nodes.length === 0) {
229229
rule.remove()

0 commit comments

Comments
 (0)