Skip to content

Commit 3813f03

Browse files
Bare values: Disallow zeros in decimal places (#14562)
I noticed some more unexpected values being passed through as _bare values_: Decimal places with zero. These should not generate CSS but currently does: - `from-25.%` - `from-25.0%` - `from-25.00%` - etc.
1 parent 30fbc2c commit 3813f03

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
- _Experimental_: Ensure we don't lose selectors when running codemods ([#14518](https://github.com/tailwindlabs/tailwindcss/pull/14518))
2929
- _Experimental_: inject `@import` in a more expected location when running codemods ([#14536](https://github.com/tailwindlabs/tailwindcss/pull/14536))
3030

31+
### Changed
32+
33+
- Disallow bare values with decimal places ([#14562](https://github.com/tailwindlabs/tailwindcss/pull/14562))
34+
3135
## [4.0.0-alpha.25] - 2024-09-24
3236

3337
### Added

packages/tailwindcss/src/utilities.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10044,6 +10044,8 @@ test('from', async () => {
1004410044
expect(
1004510045
await run([
1004610046
'from',
10047+
'from-25.%',
10048+
'from-25.0%',
1004710049
'from-123',
1004810050
'from--123',
1004910051
'from--5%',

packages/tailwindcss/src/utils/infer-data-type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,5 +326,5 @@ function isVector(value: string) {
326326
*/
327327
export function isPositiveInteger(value: any) {
328328
let num = Number(value)
329-
return Number.isInteger(num) && num >= 0
329+
return Number.isInteger(num) && num >= 0 && String(num) === String(value)
330330
}

0 commit comments

Comments
 (0)