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.
This commit is contained in:
Philipp Spiess 2024-10-01 16:06:43 +02:00 • committed by GitHub
parent 30fbc2c707
commit 3813f03b79
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 1 deletions

View file

@ -28,6 +28,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- _Experimental_: Ensure we don't lose selectors when running codemods ([#14518](https://github.com/tailwindlabs/tailwindcss/pull/14518))
- _Experimental_: inject `@import` in a more expected location when running codemods ([#14536](https://github.com/tailwindlabs/tailwindcss/pull/14536))
### Changed
- Disallow bare values with decimal places ([#14562](https://github.com/tailwindlabs/tailwindcss/pull/14562))
## [4.0.0-alpha.25] - 2024-09-24
### Added

View file

@ -10044,6 +10044,8 @@ test('from', async () => {
expect(
await run([
'from',
'from-25.%',
'from-25.0%',
'from-123',
'from--123',
'from--5%',

View file

@ -326,5 +326,5 @@ function isVector(value: string) {
*/
export function isPositiveInteger(value: any) {
let num = Number(value)
return Number.isInteger(num) && num >= 0
return Number.isInteger(num) && num >= 0 && String(num) === String(value)
}