Skip to content

Commit dc60f7a

Browse files
committed
drop any --tw-* if another property with the same value exists
This way we don't have to hardcode the edge cases, but we have to make sure that the same value exists _somewhere_. We also make sure that the other property is also not a CSS variable. Otherwise we would run into: ```css .foo { --tw-a: 1; --tw-b: 1; --tw-c: 1; } ``` Because this would delete all the declarations
1 parent e1a6375 commit dc60f7a

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

packages/tailwindcss/src/signatures.ts

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -108,27 +108,16 @@ function canonicalizeAst(ast: AstNode[], options: SignatureOptions) {
108108

109109
// Ignore `--tw-{property}` if `{property}` exists with the same value
110110
if (node.property.startsWith('--tw-')) {
111-
let siblings = ctx.parent?.nodes
112-
if (siblings) {
113-
let other = node.property.slice(5)
114-
115-
// Edge cases:
116-
//
117-
// `leading-*` sets `--tw-leading` but the property is `line-height`
118-
if (node.property === '--tw-leading') other = 'line-height'
119-
if (node.property === '--tw-tracking') other = 'letter-spacing'
120-
121-
if (
122-
siblings.some(
123-
(sibling) =>
124-
sibling.kind === 'declaration' &&
125-
sibling.property === other &&
126-
node.value === sibling.value &&
127-
node.important === sibling.important,
128-
)
129-
) {
130-
return WalkAction.Replace([])
131-
}
111+
if (
112+
(ctx.parent?.nodes ?? []).some(
113+
(sibling) =>
114+
sibling.kind === 'declaration' &&
115+
node.value === sibling.value &&
116+
node.important === sibling.important &&
117+
!sibling.property.startsWith('--tw-'),
118+
)
119+
) {
120+
return WalkAction.Replace([])
132121
}
133122
}
134123

0 commit comments

Comments
 (0)