carto/lib/less/tree/directive.js
cloudhead ba2cfe9265 cleanup ruleset evaluation
- remove eval() from ruleset.toCSS
- fix multiple mixin calls with different arguments yeilding the same
  output.
2010-07-23 19:46:48 -04:00

34 lines
1.1 KiB
JavaScript

(function (tree) {
tree.Directive = function (name, value) {
this.name = name;
if (Array.isArray(value)) {
this.ruleset = new(tree.Ruleset)([], value);
} else {
this.value = value;
}
};
tree.Directive.prototype = {
toCSS: function (ctx, env) {
if (this.ruleset) {
this.ruleset.root = true;
return this.name + (env.compress ? '{' : ' {\n ') +
this.ruleset.toCSS(ctx, env).trim().replace(/\n/g, '\n ') +
(env.compress ? '}': '\n}\n');
} else {
return this.name + ' ' + this.value.toCSS() + ';\n';
}
},
eval: function (env) {
env.frames.unshift(this);
this.ruleset = this.ruleset && this.ruleset.eval(env);
env.frames.shift();
return this;
},
variable: function (name) { return tree.Ruleset.prototype.variable.call(this.ruleset, name) },
find: function () { return tree.Ruleset.prototype.find.apply(this.ruleset, arguments) },
rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.ruleset) }
};
})(require('less/tree'));