Skip to content

Commit f1aeba3

Browse files
committed
handle -0 values for space-x-* and space-y-*
1 parent 1ae070e commit f1aeba3

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

packages/tailwindcss/src/utilities.test.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9926,6 +9926,9 @@ test('space-x', async () => {
99269926
'space-x-0',
99279927
'space-x-[0]',
99289928
'space-x-[0px]',
9929+
'-space-x-0',
9930+
'space-x-[-0]',
9931+
'space-x-[-0px]',
99299932
'space-x-1',
99309933
'-space-x-1',
99319934
'space-x-4',
@@ -9955,6 +9958,11 @@ test('space-x', async () => {
99559958
--spacing-4: 1rem;
99569959
}
99579960

9961+
:where(.-space-x-0 > :not(:last-child)) {
9962+
--tw-space-x-reverse: 0;
9963+
margin-inline: 0;
9964+
}
9965+
99589966
:where(.-space-x-1 > :not(:last-child)) {
99599967
--tw-space-x-reverse: 0;
99609968
margin-inline-start: calc(calc(var(--spacing) * -1) * var(--tw-space-x-reverse));
@@ -9984,7 +9992,7 @@ test('space-x', async () => {
99849992
margin-inline-end: calc(var(--spacing-4) * calc(1 - var(--tw-space-x-reverse)));
99859993
}
99869994

9987-
:where(.space-x-\\[0\\] > :not(:last-child)), :where(.space-x-\\[0px\\] > :not(:last-child)) {
9995+
:where(.space-x-\\[-0\\] > :not(:last-child)), :where(.space-x-\\[-0px\\] > :not(:last-child)), :where(.space-x-\\[0\\] > :not(:last-child)), :where(.space-x-\\[0px\\] > :not(:last-child)) {
99889996
--tw-space-x-reverse: 0;
99899997
margin-inline: 0;
99909998
}
@@ -10012,6 +10020,9 @@ test('space-y', async () => {
1001210020
'space-y-0',
1001310021
'space-y-[0]',
1001410022
'space-y-[0px]',
10023+
'-space-y-0',
10024+
'space-y-[-0]',
10025+
'space-y-[-0px]',
1001510026
'space-y-1',
1001610027
'-space-y-1',
1001710028
'space-y-4',
@@ -10041,6 +10052,11 @@ test('space-y', async () => {
1004110052
--spacing-4: 1rem;
1004210053
}
1004310054

10055+
:where(.-space-y-0 > :not(:last-child)) {
10056+
--tw-space-y-reverse: 0;
10057+
margin-block: 0;
10058+
}
10059+
1004410060
:where(.-space-y-1 > :not(:last-child)) {
1004510061
--tw-space-y-reverse: 0;
1004610062
margin-block-start: calc(calc(var(--spacing) * -1) * var(--tw-space-y-reverse));
@@ -10070,7 +10086,7 @@ test('space-y', async () => {
1007010086
margin-block-end: calc(var(--spacing-4) * calc(1 - var(--tw-space-y-reverse)));
1007110087
}
1007210088

10073-
:where(.space-y-\\[0\\] > :not(:last-child)), :where(.space-y-\\[0px\\] > :not(:last-child)) {
10089+
:where(.space-y-\\[-0\\] > :not(:last-child)), :where(.space-y-\\[-0px\\] > :not(:last-child)), :where(.space-y-\\[0\\] > :not(:last-child)), :where(.space-y-\\[0px\\] > :not(:last-child)) {
1007410090
--tw-space-y-reverse: 0;
1007510091
margin-block: 0;
1007610092
}

packages/tailwindcss/src/utilities.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,6 +2123,7 @@ export function createUtilities(theme: Theme) {
21232123
(value) => {
21242124
let zero = (() => {
21252125
if (value === '--spacing(0)') return true
2126+
if (value === '--spacing(-0)') return true
21262127

21272128
let parsed = dimensions.get(value)
21282129
if (parsed && parsed[0] === 0) return true
@@ -2153,6 +2154,7 @@ export function createUtilities(theme: Theme) {
21532154
(value) => {
21542155
let zero = (() => {
21552156
if (value === '--spacing(0)') return true
2157+
if (value === '--spacing(-0)') return true
21562158

21572159
let parsed = dimensions.get(value)
21582160
if (parsed && parsed[0] === 0) return true

0 commit comments

Comments
 (0)