Skip to content
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

Master fix 4252 #4295

Merged
merged 2 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion packages/less/src/less/tree/query-in-parens.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { copy } from 'copy-anything';
import Declaration from './declaration';
import Node from './node';

const QueryInParens = function (op, l, m, op2, r, i) {
Expand All @@ -7,6 +9,7 @@ const QueryInParens = function (op, l, m, op2, r, i) {
this.op2 = op2 ? op2.trim() : null;
this.rvalue = r;
this._index = i;
this.mvalues = [];
};

QueryInParens.prototype = Object.assign(new Node(), {
Expand All @@ -22,7 +25,38 @@ QueryInParens.prototype = Object.assign(new Node(), {

eval(context) {
this.lvalue = this.lvalue.eval(context);
this.mvalue = this.mvalue.eval(context);

let variableDeclaration;
let rule;

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

return false;
});

if (variableDeclaration) {
break;
}
}
}

if (!this.mvalueCopy) {
this.mvalueCopy = copy(this.mvalue);
}

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

if (this.rvalue) {
this.rvalue = this.rvalue.eval(context);
}
Expand All @@ -32,6 +66,9 @@ QueryInParens.prototype = Object.assign(new Node(), {
genCSS(context, output) {
this.lvalue.genCSS(context, output);
output.add(' ' + this.op + ' ');
if (this.mvalues.length > 0) {
this.mvalue = this.mvalues.shift();
}
this.mvalue.genCSS(context, output);
if (this.rvalue) {
output.add(' ' + this.op2 + ' ');
Expand Down
19 changes: 19 additions & 0 deletions packages/test-data/css/_main/container.css
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,22 @@
margin: 0.5em 0 0 0;
}
}
.wrapper {
container-name: wrapper;
container-type: size;
}
@container wrapper (height < 100) {
a {
max-height: 100;
}
}
@container wrapper (height < 200) {
a {
max-height: 200;
}
}
@container wrapper (height < 300) {
a {
max-height: 300;
}
}
17 changes: 17 additions & 0 deletions packages/test-data/less/_main/container.less
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,20 @@
}
}
}

.wrapper {
container-name: wrapper;
container-type: size;
}

.my_mixin(@height) {
@container wrapper (height < @height) {
a {
max-height: @height;
}
}
}

.my_mixin(100);
.my_mixin(200);
.my_mixin(300);
Loading