Skip to content

Commit

Permalink
remove the reversed orderedUtilityMap
Browse files Browse the repository at this point in the history
We don't require this reversed map since we can already sort by the
index on the node directly. Therefore this can be dropped.
  • Loading branch information
RobinMalfait authored and adamwathan committed Aug 18, 2020
1 parent 88888fd commit e39fd6f
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/flagged/applyComplexClasses.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,11 @@ function mergeAdjacentRules(initialRule, rulesToInsert) {

function makeExtractUtilityRules(css, config) {
const utilityMap = buildUtilityMap(css)
const orderUtilityMap = _.fromPairs(
_.flatMap(_.toPairs(utilityMap), ([_utilityName, utilities]) => {
return utilities.map(utility => {
return [utility.index, utility]
})
})
)
return function(utilityNames, rule) {
return _.flatMap(utilityNames, utilityName => {

return function extractUtilityRules(utilityNames, rule) {
const combined = []

utilityNames.forEach(utilityName => {
if (utilityMap[utilityName] === undefined) {
// Look for prefixed utility in case the user has goofed
const prefixedUtility = prefixSelector(config.prefix, `.${utilityName}`).slice(1)
Expand All @@ -163,10 +159,11 @@ function makeExtractUtilityRules(css, config) {
{ word: utilityName }
)
}
return utilityMap[utilityName].map(({ index }) => index)

combined.push(...utilityMap[utilityName])
})
.sort((a, b) => a - b)
.map(i => orderUtilityMap[i])

return combined.sort((a, b) => a.index - b.index)
}
}

Expand Down

0 comments on commit e39fd6f

Please sign in to comment.