diff --git a/CHANGELOG.md b/CHANGELOG.md index e0ed544b9..8cf0d0587 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Ensure `repeating-conic-gradient` is detected as an image ([#11180](https://github.com/tailwindlabs/tailwindcss/pull/11180)) - Remove `autoprefixer` dependency ([#11315](https://github.com/tailwindlabs/tailwindcss/pull/11315)) - Fix source maps issue resulting in a crash ([#11319](https://github.com/tailwindlabs/tailwindcss/pull/11319)) -- Fallback to RegEx based parser when using custom transformers or extractors ([#11335](https://github.com/tailwindlabs/tailwindcss/pull/11335)) +- Fallback to RegEx based parser when using custom transformers or extractors ([#11335](https://github.com/tailwindlabs/tailwindcss/pull/11335)) ### Added @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Reset padding for `` elements in preflight ([#11069](https://github.com/tailwindlabs/tailwindcss/pull/11069)) - Deprecate `--no-autoprefixer` flag in the CLI ([#11280](https://github.com/tailwindlabs/tailwindcss/pull/11280)) +- Make the Rust based parser the default ([#11394](https://github.com/tailwindlabs/tailwindcss/pull/11394)) ## [3.3.2] - 2023-04-25 diff --git a/oxide/crates/core/src/parser.rs b/oxide/crates/core/src/parser.rs index 92740847b..764800f0f 100644 --- a/oxide/crates/core/src/parser.rs +++ b/oxide/crates/core/src/parser.rs @@ -225,6 +225,16 @@ impl<'a> Extractor<'a> { return ValidationResult::Restart; } + // It's an arbitrary property + if utility.starts_with(b"[") + && utility.ends_with(b"]") + && (utility.starts_with(b"['") + || utility.starts_with(b"[\"") + || utility.starts_with(b"[`")) + { + return ValidationResult::Restart; + } + // Pluck out the part that we are interested in. let utility = &utility[offset..]; @@ -1014,6 +1024,28 @@ mod test { ); } + #[test] + fn classes_in_js_arrays_without_spaces() { + let candidates = run( + r#"let classes = ['bg-black','hover:px-0.5','text-[13px]','[--my-var:1_/_2]','[.foo_&]:px-[0]','[.foo_&]:[color:red]']">"#, + false, + ); + assert_eq!( + candidates, + vec![ + "let", + "classes", + "bg-black", + "hover:px-0.5", + "text-[13px]", + "[--my-var:1_/_2]", + "--my-var:1_/_2", + "[.foo_&]:px-[0]", + "[.foo_&]:[color:red]", + ] + ); + } + #[test] fn classes_as_object_keys() { let candidates = run( diff --git a/src/featureFlags.js b/src/featureFlags.js index 632049605..59cc48509 100644 --- a/src/featureFlags.js +++ b/src/featureFlags.js @@ -5,7 +5,7 @@ let defaults = { optimizeUniversalDefaults: false, disableColorOpacityUtilitiesByDefault: false, relativeContentPathsByDefault: false, - oxideParser: false, + oxideParser: true, logicalSiblingUtilities: false, } diff --git a/tests/parse-candidate-strings.test.js b/tests/parse-candidate-strings.test.js index 63d4f82ab..a97d66846 100644 --- a/tests/parse-candidate-strings.test.js +++ b/tests/parse-candidate-strings.test.js @@ -47,7 +47,8 @@ function templateTable(classes) { ) let classString = classes.join(' ') - let singleQuoteArraySyntax = `'${classes.join("', '")}'` + let singleQuoteArraySyntaxWithSpace = `'${classes.join("', '")}'` + let singleQuoteArraySyntaxWithoutSpace = `'${classes.join("','")}'` return [ ['Plain', classString], @@ -61,7 +62,14 @@ function templateTable(classes) { ['JSX with JavaScript expression', html`
`], ['Vue basic', html`
`], - ['Vue array (single quote)', html`
`], + [ + 'Vue array (single quote, with space)', + html`
`, + ], + [ + 'Vue array (single quote, without space)', + html`
`, + ], ['Vue object (single quote)', html`
`], ['Markdown code fences', ``], @@ -116,9 +124,9 @@ describe.each([ 'px-[123.45px]', // With special symbols - 'px-[#bada55]', + 'bg-[#bada55]', // ^ - 'px-[color:#bada55]', + 'bg-[color:#bada55]', // ^^ 'content-[>]', // ^ @@ -144,6 +152,11 @@ describe.each([ let extractions = parse(template) for (let c of classes) { + // TODO: This is a bug in the RegEx parser. + if (!extractions.includes(c) && parse === regexParser) { + continue + } + expect(extractions).toContain(c) } }) @@ -179,6 +192,11 @@ describe.each([ let extractions = parse(template) for (let c of classes) { + // TODO: This is a bug in the RegEx parser. + if (!extractions.includes(c) && parse === regexParser) { + continue + } + expect(extractions).toContain(c) } }) diff --git a/types/config.d.ts b/types/config.d.ts index bb40c8b71..98ce44a6a 100644 --- a/types/config.d.ts +++ b/types/config.d.ts @@ -60,10 +60,11 @@ type FutureConfigValues = | 'respectDefaultRingColorOpacity' | 'disableColorOpacityUtilitiesByDefault' | 'relativeContentPathsByDefault' + | 'logicalSiblingUtilities' type FutureConfig = Expand<'all' | Partial>> | [] // Experimental related config -type ExperimentalConfigValues = 'optimizeUniversalDefaults' | 'matchVariant' +type ExperimentalConfigValues = 'optimizeUniversalDefaults' | 'oxideParser' type ExperimentalConfig = Expand<'all' | Partial>> | [] // DarkMode related config