From 4a0dc91d477d217641b9305a7d68775d214f88b4 Mon Sep 17 00:00:00 2001 From: Daniel Puckowski Date: Sat, 30 Nov 2024 05:51:25 -0500 Subject: [PATCH] refactor: clean up fix for issue 4252 * Refactor and clean up fix for issue #4252. --- packages/less/src/less/tree/query-in-parens.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/less/src/less/tree/query-in-parens.js b/packages/less/src/less/tree/query-in-parens.js index 892063a51..40b48a71c 100644 --- a/packages/less/src/less/tree/query-in-parens.js +++ b/packages/less/src/less/tree/query-in-parens.js @@ -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; } } @@ -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 {