Skip to content

Commit ee06c23

Browse files
committed
Revert "Support using variables as arbitrary values without var()"
1 parent e07397a commit ee06c23

File tree

4 files changed

+2
-81
lines changed

4 files changed

+2
-81
lines changed

CHANGELOG.md

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

1212
- Add `line-height` modifier support to `font-size` utilities ([#9875](https://github.com/tailwindlabs/tailwindcss/pull/9875))
13-
- Support using variables as arbitrary values without `var(...)` ([#9880](https://github.com/tailwindlabs/tailwindcss/pull/9880), [#9962](https://github.com/tailwindlabs/tailwindcss/pull/9962))
1413
- Add standalone CLI build for 64-bit Windows on ARM (`node16-win-arm64`) ([#10001](https://github.com/tailwindlabs/tailwindcss/pull/10001))
1514
- [Oxide] Use `lightningcss` for nesting and vendor prefixes in PostCSS plugin ([#10399](https://github.com/tailwindlabs/tailwindcss/pull/10399))
1615

src/util/dataTypes.js

-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ const placeholderRe = new RegExp(placeholder, 'g')
1616
// This is not a data type, but rather a function that can normalize the
1717
// correct values.
1818
export function normalize(value, isRoot = true) {
19-
if (value.startsWith('--')) {
20-
return `var(${value})`
21-
}
22-
2319
// Keep raw strings if it starts with `url(`
2420
if (value.includes('url(')) {
2521
return value

src/util/pluginUtils.js

+2-10
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,6 @@ export function parseColorFormat(value) {
133133
return value
134134
}
135135

136-
function unwrapArbitraryModifier(modifier) {
137-
modifier = modifier.slice(1, -1)
138-
if (modifier.startsWith('--')) {
139-
modifier = `var(${modifier})`
140-
}
141-
return modifier
142-
}
143-
144136
export function asColor(modifier, options = {}, { tailwindConfig = {} } = {}) {
145137
if (options.values?.[modifier] !== undefined) {
146138
return parseColorFormat(options.values?.[modifier])
@@ -161,7 +153,7 @@ export function asColor(modifier, options = {}, { tailwindConfig = {} } = {}) {
161153
normalizedColor = parseColorFormat(normalizedColor)
162154

163155
if (isArbitraryValue(alpha)) {
164-
return withAlphaValue(normalizedColor, unwrapArbitraryModifier(alpha))
156+
return withAlphaValue(normalizedColor, alpha.slice(1, -1))
165157
}
166158

167159
if (tailwindConfig.theme?.opacity?.[alpha] === undefined) {
@@ -295,7 +287,7 @@ export function* getMatchingTypes(types, rawModifier, options, tailwindConfig) {
295287
if (configValue !== null) {
296288
utilityModifier = configValue
297289
} else if (isArbitraryValue(utilityModifier)) {
298-
utilityModifier = unwrapArbitraryModifier(utilityModifier)
290+
utilityModifier = utilityModifier.slice(1, -1)
299291
}
300292
}
301293
}

tests/arbitrary-values.test.js

-66
Original file line numberDiff line numberDiff line change
@@ -545,70 +545,4 @@ crosscheck(({ stable, oxide }) => {
545545
`)
546546
})
547547
})
548-
549-
it('can use CSS variables as arbitrary values without `var()`', () => {
550-
let config = {
551-
content: [
552-
{
553-
raw: html`<div
554-
class="w-[--width-var] bg-[--color-var] bg-[--color-var,#000] bg-[length:--size-var] text-[length:--size-var,12px]"
555-
></div>`,
556-
},
557-
],
558-
corePlugins: { preflight: false },
559-
plugins: [],
560-
}
561-
562-
let input = css`
563-
@tailwind utilities;
564-
`
565-
566-
return run(input, config).then((result) => {
567-
expect(result.css).toMatchFormattedCss(css`
568-
.w-\[--width-var\] {
569-
width: var(--width-var);
570-
}
571-
.bg-\[--color-var\,\#000\] {
572-
background-color: var(--color-var, #000);
573-
}
574-
.bg-\[--color-var\] {
575-
background-color: var(--color-var);
576-
}
577-
.bg-\[length\:--size-var\] {
578-
background-size: var(--size-var);
579-
}
580-
.text-\[length\:--size-var\,12px\] {
581-
font-size: var(--size-var, 12px);
582-
}
583-
`)
584-
})
585-
})
586-
587-
it('can use CSS variables as arbitrary modifiers without `var()`', () => {
588-
let config = {
589-
content: [
590-
{
591-
raw: html`<div class="text-sm/[--line-height] bg-red-500/[--opacity]"></div>`,
592-
},
593-
],
594-
corePlugins: { preflight: false },
595-
plugins: [],
596-
}
597-
598-
let input = css`
599-
@tailwind utilities;
600-
`
601-
602-
return run(input, config).then((result) => {
603-
expect(result.css).toMatchFormattedCss(css`
604-
.bg-red-500\/\[--opacity\] {
605-
background-color: rgb(239 68 68 / var(--opacity));
606-
}
607-
.text-sm\/\[--line-height\] {
608-
font-size: 0.875rem;
609-
line-height: var(--line-height);
610-
}
611-
`)
612-
})
613-
})
614548
})

0 commit comments

Comments
 (0)