Files
less.js/lib/less/tree/element.js
Alexis Sellier e35dc0efc0 merge
2011-11-12 13:49:41 +01:00

37 lines
954 B
JavaScript

(function (tree) {
tree.Element = function (combinator, value, index) {
this.combinator = combinator instanceof tree.Combinator ?
combinator : new(tree.Combinator)(combinator);
this.value = value ? value.trim() : "";
this.index = index;
};
tree.Element.prototype.toCSS = function (env) {
return this.combinator.toCSS(env || {}) + this.value;
};
tree.Combinator = function (value) {
if (value === ' ') {
this.value = ' ';
} else if (value === '& ') {
this.value = '& ';
} else {
this.value = value ? value.trim() : "";
}
};
tree.Combinator.prototype.toCSS = function (env) {
return {
'' : '',
' ' : ' ',
'&' : '',
'& ' : ' ',
':' : ' :',
'::': '::',
'+' : env.compress ? '+' : ' + ',
'~' : env.compress ? '~' : ' ~ ',
'>' : env.compress ? '>' : ' > '
}[this.value];
};
})(require('../tree'));