mirror of
https://github.com/less/less.js.git
synced 2026-01-22 21:58:14 -05:00
35 lines
925 B
JavaScript
35 lines
925 B
JavaScript
var Node = require("./node");
|
|
|
|
var Value = function (value) {
|
|
this.value = value;
|
|
if (!value) {
|
|
throw new Error("Value requires an array argument");
|
|
}
|
|
};
|
|
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 (context) {
|
|
if (this.value.length === 1) {
|
|
return this.value[0].eval(context);
|
|
} else {
|
|
return new Value(this.value.map(function (v) {
|
|
return v.eval(context);
|
|
}));
|
|
}
|
|
};
|
|
Value.prototype.genCSS = function (context, output) {
|
|
var i;
|
|
for (i = 0; i < this.value.length; i++) {
|
|
this.value[i].genCSS(context, output);
|
|
if (i + 1 < this.value.length) {
|
|
output.add((context && context.compress) ? ',' : ', ');
|
|
}
|
|
}
|
|
};
|
|
module.exports = Value;
|