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

The guarded namespace can use when the mixin is invoked #3725

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/less/src/less/tree/ruleset.js
Expand Up @@ -264,7 +264,8 @@ Ruleset.prototype = Object.assign(new Node(), {
// lets you call a css selector with a guard
matchCondition(args, context) {
const lastSelector = this.selectors[this.selectors.length - 1];
if (!lastSelector.evaldCondition) {
// fix:3407
if (!lastSelector.evaldCondition && !lastSelector.condition) {
return false;
}
if (lastSelector.condition &&
Expand Down
12 changes: 12 additions & 0 deletions packages/test-data/css/_main/mixins-guards.css
Expand Up @@ -173,6 +173,18 @@
#guarded-deeper {
should: match 1;
}
@media (min-width: 700px) {
.example1 {
success1: 1;
success2: 2;
success3: 3;
}
}
@media (min-width: 700px) {
.example2 {
wut: 1;
}
}
#parenthesisNot-true {
parenthesisNot: just-value;
parenthesisNot: negated twice 1;
Expand Down
37 changes: 37 additions & 0 deletions packages/test-data/less/_main/mixins-guards.less
Expand Up @@ -270,6 +270,43 @@
#top > #deeper > .mixin(1);
}

// guarded namespaced should pass when true
#desktop (@ruleset) {
@media (min-width: 700px) {
@ruleset();
}
}

@switch: demo;

.example1 {
#lookup when (@switch = demo) {
@not-found: 1;
}

@found: 2;

#lookup2 {
@also-found: 3;
}

#desktop({
success1: #lookup[@not-found];
success2: @found;
success3: #lookup2[@also-found];
});
}

.example2 {
#lookup () when (@switch = demo) {
@not-found: 1;
}

#desktop({
wut: #lookup[@not-found];
});
}

// namespaced & guarded mixin in root
// outputs nothing but should pass:

Expand Down