mirror of
https://github.com/less/less.js.git
synced 2026-01-23 06:07:56 -05:00
53 lines
1.6 KiB
JavaScript
53 lines
1.6 KiB
JavaScript
(function (tree) {
|
|
|
|
tree.Expression = function (value) { this.value = value; };
|
|
tree.Expression.prototype = {
|
|
type: "Expression",
|
|
accept: function (visitor) {
|
|
this.value = visitor.visit(this.value);
|
|
},
|
|
eval: function (env) {
|
|
var returnValue,
|
|
inParenthesis = this.parens && !this.parensInOp,
|
|
doubleParen = false;
|
|
if (inParenthesis) {
|
|
env.inParenthesis();
|
|
}
|
|
if (this.value.length > 1) {
|
|
returnValue = new(tree.Expression)(this.value.map(function (e) {
|
|
return e.eval(env);
|
|
}));
|
|
} else if (this.value.length === 1) {
|
|
if (this.value[0].parens && !this.value[0].parensInOp) {
|
|
doubleParen = true;
|
|
}
|
|
returnValue = this.value[0].eval(env);
|
|
} else {
|
|
returnValue = this;
|
|
}
|
|
if (inParenthesis) {
|
|
env.outOfParenthesis();
|
|
}
|
|
if (this.parens && this.parensInOp && !(env.isMathOn()) && !doubleParen) {
|
|
returnValue = new(tree.Paren)(returnValue);
|
|
}
|
|
return returnValue;
|
|
},
|
|
genCSS: function (env, output) {
|
|
for(var i = 0; i < this.value.length; i++) {
|
|
this.value[i].genCSS(env, output);
|
|
if (i + 1 < this.value.length) {
|
|
output.add(" ");
|
|
}
|
|
}
|
|
},
|
|
toCSS: tree.toCSS,
|
|
throwAwayComments: function () {
|
|
this.value = this.value.filter(function(v) {
|
|
return !(v instanceof tree.Comment);
|
|
});
|
|
}
|
|
};
|
|
|
|
})(require('../tree'));
|