Skip to content

Commit f7d8f2f

Browse files
committed
remove any date type for decoration plugin
The main reason for the `any` type is so that we don't have to parse the value and can assume that this plugin handles "any" value you give it. This is useful because `decoration-[var(--something)]` would be correctly translated to the correct decoration property. However, we introduce another plugin with the same `decoration` prefix. This means that now both `textDecorationColor` and `textDecorationThickness` have the same base utility name: `decoration`. - `textDecorationColor` had ['color', 'any'] - `textDecorationThickness` had ['length', 'percentage'] This means that `3px` fit both in the `length` data type of the `textDecorationThickness` plugin and in the `any` data type of the `textDecorationColor` plugin. Removing the `any` fixes this. TL;DR: Only have `any` when there are no conflicting utility names.
1 parent 6b82ca8 commit f7d8f2f

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/corePlugins.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,7 @@ export let corePlugins = {
16701670
return { 'text-decoration-color': toColorValue(value) }
16711671
},
16721672
},
1673-
{ values: flattenColorPalette(theme('textDecorationColor')), type: ['color', 'any'] }
1673+
{ values: flattenColorPalette(theme('textDecorationColor')), type: ['color'] }
16741674
)
16751675
},
16761676

tests/arbitrary-values.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,28 @@ test('arbitrary values', () => {
1616
})
1717
})
1818

19+
it('should be possible to differentiate between decoration utilities', () => {
20+
let config = {
21+
content: [
22+
{
23+
raw: html` <div class="decoration-[3px] decoration-[#ccc]"></div> `,
24+
},
25+
],
26+
}
27+
28+
return run('@tailwind utilities', config).then((result) => {
29+
return expect(result.css).toMatchFormattedCss(css`
30+
.decoration-\[\#ccc\] {
31+
text-decoration-color: #ccc;
32+
}
33+
34+
.decoration-\[3px\] {
35+
text-decoration-thickness: 3px;
36+
}
37+
`)
38+
})
39+
})
40+
1941
it('should support modifiers for arbitrary values that contain the separator', () => {
2042
let config = {
2143
content: [

0 commit comments

Comments
 (0)