diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ef780e40..a637d0352 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Update types to work with `Node16` module resolution ([#12097](https://github.com/tailwindlabs/tailwindcss/pull/12097)) - Don’t crash when important and parent selectors are equal in `@apply` ([#12112](https://github.com/tailwindlabs/tailwindcss/pull/12112)) - Eliminate irrelevant rules when applying variants ([#12113](https://github.com/tailwindlabs/tailwindcss/pull/12113)) +- Improve RegEx parser, reduce possibilities as the key for arbitrary properties ([#12121](https://github.com/tailwindlabs/tailwindcss/pull/12121)) ## [3.3.3] - 2023-07-13 diff --git a/src/lib/defaultExtractor.js b/src/lib/defaultExtractor.js index c56597e92..5d63ef653 100644 --- a/src/lib/defaultExtractor.js +++ b/src/lib/defaultExtractor.js @@ -12,10 +12,12 @@ export function defaultExtractor(context) { let results = [] for (let pattern of patterns) { - results = [...results, ...(content.match(pattern) ?? [])] + for (let result of content.match(pattern) ?? []) { + results.push(clipAtBalancedParens(result)) + } } - return results.filter((v) => v !== undefined).map(clipAtBalancedParens) + return results } } @@ -34,7 +36,7 @@ function* buildRegExps(context) { // This is a targeted fix to continue to allow theme() // with square brackets to work in arbitrary properties // while fixing a problem with the regex matching too much - /\[[^\s:'"`]+:[^\s]+?\[[^\s]+\][^\s]+?\]/, + /\[[^\s:'"`\]]+:[^\s]+?\[[^\s]+\][^\s]+?\]/, // Utilities regex.pattern([