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

Nested mixin changing important 2421 #2427

Merged
merged 2 commits into from
Feb 1, 2015
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
13 changes: 12 additions & 1 deletion lib/less/tree/mixin-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ Definition.prototype.evalParams = function (context, mixinEnv, args, evaldArgume

return frame;
};
Definition.prototype.makeImportant = function() {
var rules = !this.rules ? this.rules : this.rules.map(function (r) {
if (r.makeImportant) {
return r.makeImportant(true);
} else {
return r;
}
});
var result = new Definition (this.name, this.params, rules, this.condition, this.variadic, this.frames);
return result;
};
Definition.prototype.eval = function (context) {
return new Definition(this.name, this.params, this.rules, this.condition, this.variadic, this.frames || context.frames.slice(0));
};
Expand All @@ -129,7 +140,7 @@ Definition.prototype.evalCall = function (context, args, important) {
ruleset.originalRuleset = this;
ruleset = ruleset.eval(new contexts.Eval(context, [this, frame].concat(mixinFrames)));
if (important) {
ruleset = this.makeImportant.apply(ruleset);
ruleset = ruleset.makeImportant();
}
return ruleset;
};
Expand Down
10 changes: 6 additions & 4 deletions lib/less/tree/ruleset.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,17 @@ Ruleset.prototype.evalImports = function(context) {
}
};
Ruleset.prototype.makeImportant = function() {
this.rules = this.rules.map(function (r) {
var result = new Ruleset(this.selectors, this.rules.map(function (r) {
if (r.makeImportant) {
return r.makeImportant();
} else {
return r;
}
});
return this;
};Ruleset.prototype.matchArgs = function (args) {
}), this.strictImports);

return result;
};
Ruleset.prototype.matchArgs = function (args) {
return !args || args.length === 0;
};
// lets you call a css selector with a guard
Expand Down
6 changes: 6 additions & 0 deletions test/css/mixins-important.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@
.when-calling-nested-with-param-issue-2394 {
width: 10px !important;
}
.class1-2421 {
margin: 5px !important;
}
.class2-2421 {
margin: 5px;
}
18 changes: 17 additions & 1 deletion test/less/mixins-important.less
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,20 @@
}
.when-calling-nested-with-param-issue-2394 {
.size(10px) !important;
}
}
.testMixin-2421 () {
.topCheck-2421 () {
.nestedCheck-2421() {
margin: 5px;
}
.nestedCheck-2421();
}
.topCheck-2421();
}
.class1-2421 {
.testMixin-2421() !important;
}
.class2-2421 {
.testMixin-2421();
}