31 lines
943 B
JavaScript
31 lines
943 B
JavaScript
if (typeof(window) === 'undefined') { var tree = require(require('path').join(__dirname, '..', '..', 'less', '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 () {
|
|
return this.combinator.toCSS() + this.value;
|
|
};
|
|
|
|
tree.Combinator = function Combinator(value) {
|
|
if (value === ' ') {
|
|
this.value = ' ';
|
|
} else {
|
|
this.value = value ? value.trim() : "";
|
|
}
|
|
};
|
|
tree.Combinator.prototype.toCSS = function () {
|
|
switch (this.value) {
|
|
case '' : return '';
|
|
case ' ' : return ' ';
|
|
case '&' : return '';
|
|
case ':' : return ' :';
|
|
case '::': return '::';
|
|
case '+' : return ' + ';
|
|
case '~' : return ' ~ ';
|
|
case '>' : return ' > ';
|
|
}
|
|
};
|