Make the Rust based parser the default (#11394)
* add failling test using array syntax without space delimiter * add Rust test with candidates in array without spaces * Fix JS arrays without spaces * make the `oxideParser` the default * sync feature flags with reality * use better example in tests to be more real * skip failing tests in the RegEx parser * update changelog * make `clippy` happy --------- Co-authored-by: Jordan Pittman <jordan@cryptica.me>
This commit is contained in:
parent
55daf8e0f5
commit
eb8d9294c5
5 changed files with 59 additions and 7 deletions
|
|
@ -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 `<dialog>` 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
|
||||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ let defaults = {
|
|||
optimizeUniversalDefaults: false,
|
||||
disableColorOpacityUtilitiesByDefault: false,
|
||||
relativeContentPathsByDefault: false,
|
||||
oxideParser: false,
|
||||
oxideParser: true,
|
||||
logicalSiblingUtilities: false,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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`<div className={"${classString}"}></div>`],
|
||||
|
||||
['Vue basic', html`<div :class="${classString}"></div>`],
|
||||
['Vue array (single quote)', html`<div :class="[${singleQuoteArraySyntax}]"></div>`],
|
||||
[
|
||||
'Vue array (single quote, with space)',
|
||||
html`<div :class="[${singleQuoteArraySyntaxWithSpace}]"></div>`,
|
||||
],
|
||||
[
|
||||
'Vue array (single quote, without space)',
|
||||
html`<div :class="[${singleQuoteArraySyntaxWithoutSpace}]"></div>`,
|
||||
],
|
||||
['Vue object (single quote)', html`<div :class="{'${classString}': true}"></div>`],
|
||||
|
||||
['Markdown code fences', `<!-- This should work \`${classString}\` -->`],
|
||||
|
|
@ -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)
|
||||
}
|
||||
})
|
||||
|
|
|
|||
3
types/config.d.ts
vendored
3
types/config.d.ts
vendored
|
|
@ -60,10 +60,11 @@ type FutureConfigValues =
|
|||
| 'respectDefaultRingColorOpacity'
|
||||
| 'disableColorOpacityUtilitiesByDefault'
|
||||
| 'relativeContentPathsByDefault'
|
||||
| 'logicalSiblingUtilities'
|
||||
type FutureConfig = Expand<'all' | Partial<Record<FutureConfigValues, boolean>>> | []
|
||||
|
||||
// Experimental related config
|
||||
type ExperimentalConfigValues = 'optimizeUniversalDefaults' | 'matchVariant'
|
||||
type ExperimentalConfigValues = 'optimizeUniversalDefaults' | 'oxideParser'
|
||||
type ExperimentalConfig = Expand<'all' | Partial<Record<ExperimentalConfigValues, boolean>>> | []
|
||||
|
||||
// DarkMode related config
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue