Skip to content

Fix parsing of theme() inside calc() when there are no spaces around operators #11157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 4, 2023
Merged
Prev Previous commit
Next Next commit
Remove workaround for calc + operators without spaces
  • Loading branch information
thecrypticace committed May 4, 2023
commit 163e105e20e0d75ae312beb862db30bb3fc516c4
5 changes: 0 additions & 5 deletions src/lib/evaluateTailwindFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import buildMediaQuery from '../util/buildMediaQuery'
import { toPath } from '../util/toPath'
import { withAlphaValue } from '../util/withAlphaVariable'
import { parseColorFormat } from '../util/pluginUtils'
import { normalizeMathOperatorSpacing } from '../util/dataTypes'
import log from '../util/log'

function isObject(input) {
Expand Down Expand Up @@ -150,10 +149,6 @@ function resolveFunctions(node, input, functions) {
let hasAnyFn = Object.keys(functions).some((fn) => input.includes(`${fn}(`))
if (!hasAnyFn) return input

// We only have to do this because of a bug in postcss-value-parser
// See: https://github.com/TrySound/postcss-value-parser/issues/86
input = normalizeMathOperatorSpacing(input)

return parseValue(input)
.walk((vNode) => {
resolveVNode(node, vNode, functions)
Expand Down
2 changes: 1 addition & 1 deletion src/util/dataTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function normalize(value, isRoot = true) {
* @param {string} value
* @returns {string}
*/
export function normalizeMathOperatorSpacing(value) {
function normalizeMathOperatorSpacing(value) {
return value.replace(/(calc|min|max|clamp)\(.+\)/g, (match) => {
let vars = []

Expand Down