Skip to content

Commit e39fd6f

Browse files
RobinMalfaitadamwathan
authored andcommitted
remove the reversed orderedUtilityMap
We don't require this reversed map since we can already sort by the index on the node directly. Therefore this can be dropped.
1 parent 88888fd commit e39fd6f

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/flagged/applyComplexClasses.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,11 @@ function mergeAdjacentRules(initialRule, rulesToInsert) {
139139

140140
function makeExtractUtilityRules(css, config) {
141141
const utilityMap = buildUtilityMap(css)
142-
const orderUtilityMap = _.fromPairs(
143-
_.flatMap(_.toPairs(utilityMap), ([_utilityName, utilities]) => {
144-
return utilities.map(utility => {
145-
return [utility.index, utility]
146-
})
147-
})
148-
)
149-
return function(utilityNames, rule) {
150-
return _.flatMap(utilityNames, utilityName => {
142+
143+
return function extractUtilityRules(utilityNames, rule) {
144+
const combined = []
145+
146+
utilityNames.forEach(utilityName => {
151147
if (utilityMap[utilityName] === undefined) {
152148
// Look for prefixed utility in case the user has goofed
153149
const prefixedUtility = prefixSelector(config.prefix, `.${utilityName}`).slice(1)
@@ -163,10 +159,11 @@ function makeExtractUtilityRules(css, config) {
163159
{ word: utilityName }
164160
)
165161
}
166-
return utilityMap[utilityName].map(({ index }) => index)
162+
163+
combined.push(...utilityMap[utilityName])
167164
})
168-
.sort((a, b) => a - b)
169-
.map(i => orderUtilityMap[i])
165+
166+
return combined.sort((a, b) => a.index - b.index)
170167
}
171168
}
172169

0 commit comments

Comments
 (0)