Skip to content

Commit

Permalink
Remove grouping prototype
Browse files Browse the repository at this point in the history
This code has been sitting around for a while disabled and untested. And it does not work with the Oxide parser. So we’re gonna remove it.
  • Loading branch information
thecrypticace committed Oct 23, 2023
1 parent 88119e2 commit 17c7609
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 303 deletions.
1 change: 0 additions & 1 deletion src/featureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ let featureFlags = {
experimental: [
'optimizeUniversalDefaults',
'generalizedModifiers',
// 'variantGrouping',
],
}

Expand Down
11 changes: 1 addition & 10 deletions src/lib/defaultExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export function defaultExtractor(context) {

function* buildRegExps(context) {
let separator = context.tailwindConfig.separator
let variantGroupingEnabled = flagEnabled(context.tailwindConfig, 'variantGrouping')
let prefix =
context.tailwindConfig.prefix !== ''
? regex.optional(regex.pattern([/-?/, regex.escape(context.tailwindConfig.prefix)]))
Expand Down Expand Up @@ -103,15 +102,7 @@ function* buildRegExps(context) {

prefix,

variantGroupingEnabled
? regex.any([
// Or any of those things but grouped separated by commas
regex.pattern([/\(/, utility, regex.zeroOrMore([/,/, utility]), /\)/]),

// Arbitrary properties, constrained utilities, arbitrary values, etc…
utility,
])
: utility,
utility,
])
}

Expand Down
15 changes: 3 additions & 12 deletions src/lib/generateRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ function* recordCandidates(matches, classCandidate) {
}
}

function* resolveMatches(candidate, context, original = candidate) {
function* resolveMatches(candidate, context) {
let separator = context.tailwindConfig.separator
let [classCandidate, ...variants] = splitWithSeparator(candidate, separator).reverse()
let important = false
Expand All @@ -583,15 +583,6 @@ function* resolveMatches(candidate, context, original = candidate) {
classCandidate = classCandidate.slice(1)
}

if (flagEnabled(context.tailwindConfig, 'variantGrouping')) {
if (classCandidate.startsWith('(') && classCandidate.endsWith(')')) {
let base = variants.slice().reverse().join(separator)
for (let part of splitAtTopLevelOnly(classCandidate.slice(1, -1), ',')) {
yield* resolveMatches(base + separator + part, context, original)
}
}
}

// TODO: Reintroduce this in ways that doesn't break on false positives
// function sortAgainst(toSort, against) {
// return toSort.slice().sort((a, z) => {
Expand Down Expand Up @@ -780,7 +771,7 @@ function* resolveMatches(candidate, context, original = candidate) {
match[1].raws.tailwind = { ...match[1].raws.tailwind, candidate }

// Apply final format selector
match = applyFinalFormat(match, { context, candidate, original })
match = applyFinalFormat(match, { context, candidate })

// Skip rules with invalid selectors
// This will cause the candidate to be added to the "not class"
Expand All @@ -794,7 +785,7 @@ function* resolveMatches(candidate, context, original = candidate) {
}
}

function applyFinalFormat(match, { context, candidate, original }) {
function applyFinalFormat(match, { context, candidate }) {
if (!match[0].collectedFormats) {
return match
}
Expand Down
280 changes: 0 additions & 280 deletions tests/variant-grouping.test.skip.js

This file was deleted.

0 comments on commit 17c7609

Please sign in to comment.