Skip to content

Commit 50802e1

Browse files
Correctly parse shadow lengths without a leading zero (#7289)
* Correctly parse shadow lengths without a leading zero * Update changelog * Fix code style
1 parent dab8b04 commit 50802e1

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

1212
- Fix preflight border color fallback ([#7288](https://github.com/tailwindlabs/tailwindcss/pull/7288))
13+
- Correctly parse shadow lengths without a leading zero ([#7289](https://github.com/tailwindlabs/tailwindcss/pull/7289))
1314

1415
## [3.0.18] - 2022-01-28
1516

src/util/parseBoxShadowValue.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
let KEYWORDS = new Set(['inset', 'inherit', 'initial', 'revert', 'unset'])
22
let COMMA = /\,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
33
let SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
4-
let LENGTH = /^-?(\d+)(.*?)$/g
4+
let LENGTH = /^-?(\d+|\.\d+)(.*?)$/g
55

66
export function parseBoxShadowValue(input) {
77
let shadows = input.split(COMMA)

tests/basic-usage.test.js

+35
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,38 @@ it('fasly config values still work', () => {
137137
`)
138138
})
139139
})
140+
141+
it('shadows support values without a leading zero', () => {
142+
let config = {
143+
content: [{ raw: html`<div class="shadow-one shadow-two"></div>` }],
144+
theme: {
145+
boxShadow: {
146+
one: '0.5rem 0.5rem 0.5rem #0005',
147+
two: '.5rem .5rem .5rem #0005',
148+
},
149+
},
150+
plugins: [],
151+
corePlugins: { preflight: false },
152+
}
153+
154+
let input = css`
155+
@tailwind utilities;
156+
`
157+
158+
return run(input, config).then((result) => {
159+
expect(result.css).toMatchFormattedCss(css`
160+
.shadow-one {
161+
--tw-shadow: 0.5rem 0.5rem 0.5rem #0005;
162+
--tw-shadow-colored: 0.5rem 0.5rem 0.5rem var(--tw-shadow-color);
163+
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
164+
var(--tw-shadow);
165+
}
166+
.shadow-two {
167+
--tw-shadow: 0.5rem 0.5rem 0.5rem #0005;
168+
--tw-shadow-colored: 0.5rem 0.5rem 0.5rem var(--tw-shadow-color);
169+
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
170+
var(--tw-shadow);
171+
}
172+
`)
173+
})
174+
})

0 commit comments

Comments
 (0)