@@ -20,7 +20,7 @@ function hasAtRule(css, atRule) {
20
20
return foundAtRule
21
21
}
22
22
23
- function applyUtility ( { rule, utilityName : className , classPosition } , replaceWith ) {
23
+ function generateRulesFromApply ( { rule, utilityName : className , classPosition } , replaceWith ) {
24
24
const processedSelectors = rule . selectors . map ( selector => {
25
25
const processor = selectorParser ( selectors => {
26
26
let i = 0
@@ -172,43 +172,43 @@ function processApplyAtRules(css, lookupTree, config) {
172
172
173
173
while ( hasAtRule ( css , 'apply' ) ) {
174
174
css . walkRules ( rule => {
175
- const injectRules = [ ]
175
+ const applyRules = [ ]
176
176
177
177
// Only walk direct children to avoid issues with nesting plugins
178
178
rule . each ( child => {
179
179
if ( child . type === 'atrule' && child . name === 'apply' ) {
180
- injectRules . unshift ( child )
180
+ applyRules . unshift ( child )
181
181
}
182
182
} )
183
183
184
- injectRules . forEach ( inject => {
184
+ applyRules . forEach ( applyRule => {
185
185
const [
186
186
importantEntries ,
187
- injectUtilityNames ,
187
+ applyUtilityNames ,
188
188
important = importantEntries . length > 0 ,
189
- ] = _ . partition ( inject . params . split ( ' ' ) , n => n === '!important' )
189
+ ] = _ . partition ( applyRule . params . split ( ' ' ) , n => n === '!important' )
190
190
191
191
const currentUtilityNames = extractUtilityNames ( rule . selector )
192
192
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 ]
195
195
throw rule . error (
196
196
`You cannot \`@apply\` the \`${ currentUtilityName } \` utility here because it creates a circular dependency.`
197
197
)
198
198
}
199
199
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
201
201
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 )
204
204
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 )
207
207
208
208
// Get new rules with the utility portion of the selector replaced with the new selector
209
209
const rulesToInsert = [
210
- ...injects . map ( injectUtility => {
211
- return applyUtility ( injectUtility , rule . selector )
210
+ ...applys . map ( applyUtility => {
211
+ return generateRulesFromApply ( applyUtility , rule . selector )
212
212
} ) ,
213
213
afterRule ,
214
214
]
@@ -219,11 +219,11 @@ function processApplyAtRules(css, lookupTree, config) {
219
219
220
220
const mergedRules = mergeAdjacentRules ( rule , nodes )
221
221
222
- inject . remove ( )
222
+ applyRule . remove ( )
223
223
rule . after ( mergedRules )
224
224
} )
225
225
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),
227
227
// remove the rule fuggit.
228
228
if ( rule . nodes . length === 0 ) {
229
229
rule . remove ( )
0 commit comments