Files
less.js/lib/less/tree/value.js

32 lines
813 B
JavaScript

var Node = require("./node.js");
var Value = function (value) {
this.value = value;
};
Value.prototype = new Node();
Value.prototype.type = "Value";
Value.prototype.accept = function (visitor) {
if (this.value) {
this.value = visitor.visitArray(this.value);
}
};
Value.prototype.eval = function (env) {
if (this.value.length === 1) {
return this.value[0].eval(env);
} else {
return new(Value)(this.value.map(function (v) {
return v.eval(env);
}));
}
};
Value.prototype.genCSS = function (env, output) {
var i;
for(i = 0; i < this.value.length; i++) {
this.value[i].genCSS(env, output);
if (i+1 < this.value.length) {
output.add((env && env.compress) ? ',' : ', ');
}
}
};
module.exports = Value;