Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve [0] arbitrary value support #6259

Merged
merged 2 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `portrait` and `landscape` variants ([#6046](https://github.com/tailwindlabs/tailwindcss/pull/6046))
- Add `text-decoration-style`, `text-decoration-thickness`, and `text-underline-offset` utilities ([#6004](https://github.com/tailwindlabs/tailwindcss/pull/6004))
- Add `menu` reset to preflight ([#6213](https://github.com/tailwindlabs/tailwindcss/pull/6213))
- Allow `0` as a valid `length` value ([#6233](https://github.com/tailwindlabs/tailwindcss/pull/6233))
- Allow `0` as a valid `length` value ([#6233](https://github.com/tailwindlabs/tailwindcss/pull/6233), [#6259](https://github.com/tailwindlabs/tailwindcss/pull/6259))
- Add css functions to data types ([#6258](https://github.com/tailwindlabs/tailwindcss/pull/6258))

### Changed
Expand Down
2 changes: 1 addition & 1 deletion src/util/dataTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ let lengthUnits = [
let lengthUnitsPattern = `(?:${lengthUnits.join('|')})`
export function length(value) {
return (
value === 0 ||
value === '0' ||
new RegExp(`${lengthUnitsPattern}$`).test(value) ||
cssFunctions.some((fn) => new RegExp(`^${fn}\\(.+?${lengthUnitsPattern}`).test(value))
)
Expand Down
3 changes: 3 additions & 0 deletions tests/arbitrary-values.test.css
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,9 @@
.font-\[\'Some_Font\'\2c var\(--other-font\)\] {
font-family: 'Some Font', var(--other-font);
}
.text-\[0\] {
font-size: 0;
}
.text-\[2\.23rem\] {
font-size: 2.23rem;
}
Expand Down
1 change: 1 addition & 0 deletions tests/arbitrary-values.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@
<div class="font-[var(--font1),var(--font2)]"></div>
<div class="font-[invalid_font_because_spaces]"></div>

<div class="text-[0]"></div>
<div class="text-[2.23rem]"></div>
<div class="text-[length:var(--font-size)]"></div>
<div class="text-[angle:var(--angle)]"></div>
Expand Down