33 lines
849 B
JavaScript
33 lines
849 B
JavaScript
(function (tree) {
|
|
|
|
tree.Element = function Element(combinator, value) {
|
|
this.combinator = combinator instanceof tree.Combinator ?
|
|
combinator : new(tree.Combinator)(combinator);
|
|
this.value = value.trim();
|
|
};
|
|
tree.Element.prototype.toCSS = function (env) {
|
|
return this.combinator.toCSS(env || {}) + this.value;
|
|
};
|
|
|
|
tree.Combinator = function Combinator(value) {
|
|
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('less/tree'));
|