mirror of
https://github.com/less/less.js.git
synced 2026-02-09 22:45:28 -05:00
Make less.js ignore nodes in its own path so infinite recursion does not happen. Fixes #413
This commit is contained in:
@@ -10,14 +10,25 @@ tree.mixin.Call = function (elements, args, index, filename, important) {
|
||||
};
|
||||
tree.mixin.Call.prototype = {
|
||||
eval: function (env) {
|
||||
var mixins, args, rules = [], match = false;
|
||||
var mixins, args, rules = [], match = false, i, m, f, isRecursive;
|
||||
|
||||
for (var i = 0; i < env.frames.length; i++) {
|
||||
for (i = 0; i < env.frames.length; i++) {
|
||||
if ((mixins = env.frames[i].find(this.selector)).length > 0) {
|
||||
|
||||
args = this.arguments && this.arguments.map(function (a) {
|
||||
return { name: a.name, value: a.value.eval(env) };
|
||||
});
|
||||
for (var m = 0; m < mixins.length; m++) {
|
||||
for (m = 0; m < mixins.length; m++) {
|
||||
isRecursive = false;
|
||||
for(f = 0; f < env.frames.length; f++) {
|
||||
if (mixins[m] === (env.frames[f].originalRuleset || env.frames[f])) {
|
||||
isRecursive = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isRecursive) {
|
||||
continue;
|
||||
}
|
||||
if (mixins[m].match(args, env)) {
|
||||
try {
|
||||
Array.prototype.push.apply(
|
||||
@@ -140,7 +151,7 @@ tree.mixin.Definition.prototype = {
|
||||
return frame;
|
||||
},
|
||||
eval: function (env, args, important) {
|
||||
var _arguments = [], frame = this.evalParams(env, args, _arguments), context, rules, start;
|
||||
var _arguments = [], frame = this.evalParams(env, args, _arguments), context, rules, start, ruleset;
|
||||
|
||||
frame.rules.unshift(new(tree.Rule)('@arguments', new(tree.Expression)(_arguments).eval(env)));
|
||||
|
||||
@@ -149,9 +160,11 @@ tree.mixin.Definition.prototype = {
|
||||
return new(tree.Rule)(r.name, r.value, '!important', r.index);
|
||||
}) : this.rules.slice(0);
|
||||
|
||||
return new(tree.Ruleset)(null, rules).eval({
|
||||
ruleset = new(tree.Ruleset)(null, rules).eval({
|
||||
frames: [this, frame].concat(this.frames, env.frames)
|
||||
});
|
||||
ruleset.originalRuleset = this;
|
||||
return ruleset;
|
||||
},
|
||||
match: function (args, env) {
|
||||
var argsLength = (args && args.length) || 0, len, frame;
|
||||
|
||||
@@ -12,6 +12,7 @@ tree.Ruleset.prototype = {
|
||||
var ruleset = new(tree.Ruleset)(selectors, this.rules.slice(0), this.strictImports);
|
||||
var rules = [];
|
||||
|
||||
ruleset.originalRuleset = this;
|
||||
ruleset.root = this.root;
|
||||
ruleset.allowImports = this.allowImports;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user