Skip to content

Commit

Permalink
refactor: clean up fix for issue 4252
Browse files Browse the repository at this point in the history
* Refactor and clean up fix for issue #4252.
  • Loading branch information
puckowski committed Nov 30, 2024
1 parent 69f2010 commit 4a0dc91
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions packages/less/src/less/tree/query-in-parens.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,20 @@ QueryInParens.prototype = Object.assign(new Node(), {
eval(context) {
this.lvalue = this.lvalue.eval(context);

let hasVariable = false;
let variableDeclaration;
let rule;

for (let i = 0; (rule = context.frames[i]); i++) {
if (rule.type === 'Ruleset') {
rule.rules.filter(function (r) {
variableDeclaration = rule.rules.find(function (r) {
if ((r instanceof Declaration) && r.variable) {
hasVariable = true;
return true;
}

return false;
});

if (hasVariable) {
if (variableDeclaration) {
break;
}
}
Expand All @@ -46,12 +48,9 @@ QueryInParens.prototype = Object.assign(new Node(), {
if (!this.mvalueCopy) {
this.mvalueCopy = copy(this.mvalue);
}

if (hasVariable) {
this.mvalue = this.mvalueCopy;
}

if (hasVariable) {
if (variableDeclaration) {
this.mvalue = this.mvalueCopy;
this.mvalue = this.mvalue.eval(context);
this.mvalues.push(this.mvalue);
} else {
Expand Down

0 comments on commit 4a0dc91

Please sign in to comment.