Skip to content

Commit 12ea363

Browse files
authored
Fix decoration utility ambiguity (#6217)
* remove `any` data type for decoration color 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. * remove utility that doesn't generate css Having `decoration-[var(--abc)]` is ambiguous because there are multiple plugins that have a `decoration` utility name. In order for this to work you have to prefix it with the type: `decoration-[color:var(--abc)]` which is already tested in this file.
1 parent 6b82ca8 commit 12ea363

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
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.css

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,9 +822,6 @@
822822
.decoration-\[color\:var\(--color\)\] {
823823
text-decoration-color: var(--color);
824824
}
825-
.decoration-\[var\(--color\)\] {
826-
text-decoration-color: var(--color);
827-
}
828825
.decoration-\[length\:10px\] {
829826
text-decoration-thickness: 10px;
830827
}

tests/arbitrary-values.test.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@
303303
<div class="decoration-[rgb(123,_123,_123)]"></div>
304304
<div class="decoration-[rgb(123_123_123)]"></div>
305305
<div class="decoration-[color:var(--color)]"></div>
306-
<div class="decoration-[var(--color)]"></div>
307306

308307
<div class="decoration-[length:10px]"></div>
309308

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)