Skip to content

Commit 154164d

Browse files
Validate bare values (#13245)
* add validation for bare values * add bare value validation to `row-span`, `row-start`, `row-end`, `row-span`, `row-start`, and `row-end` * update changelog * validate bare values in `utilities.functional` utilities * mark candidates as invalid if the leftover value is an empty string * Update packages/tailwindcss/src/candidate.ts Co-authored-by: Jordan Pittman <[email protected]> * validate `from`, `via` and `to` This way we make sure that the bare value ends with `%`, and the value before it is a number. --------- Co-authored-by: Jordan Pittman <[email protected]>
1 parent 9fc5aa1 commit 154164d

File tree

4 files changed

+271
-72
lines changed

4 files changed

+271
-72
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Inline `@import` rules in `tailwindcss/index.css` at publish time for better performance ([#13233](https://github.com/tailwindlabs/tailwindcss/pull/13233))
1313

14+
### Fixed
15+
16+
- Validate bare values ([#13245](https://github.com/tailwindlabs/tailwindcss/pull/13245))
17+
1418
## [4.0.0-alpha.9] - 2024-03-13
1519

1620
### Added

packages/tailwindcss/src/candidate.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,13 @@ export function parseCandidate(input: string, designSystem: DesignSystem): Candi
426426
? null
427427
: value.slice(valueWithoutModifier.lastIndexOf('-') + 1)
428428

429+
// If the leftover value is an empty string, it means that the value is an
430+
// invalid named value. This makes the candidate invalid and we can
431+
// skip any further parsing.
432+
if (valueWithoutModifier === '') {
433+
return null
434+
}
435+
429436
candidate.value = {
430437
kind: 'named',
431438
value: valueWithoutModifier,

0 commit comments

Comments
 (0)