2010-03-02 04:32:21 +08:00
|
|
|
if (typeof(window) === 'undefined') { var tree = require(require('path').join(__dirname, '..', '..', 'less', 'tree')); }
|
2010-02-24 02:39:05 +08:00
|
|
|
|
2010-03-02 04:32:21 +08:00
|
|
|
tree.Element = function Element(combinator, value) {
|
2010-03-05 02:48:24 +08:00
|
|
|
this.combinator = combinator instanceof tree.Combinator ?
|
|
|
|
combinator : new(tree.Combinator)(combinator);
|
2010-02-24 02:39:05 +08:00
|
|
|
this.value = value.trim();
|
|
|
|
};
|
2010-03-02 04:32:21 +08:00
|
|
|
tree.Element.prototype.toCSS = function () {
|
2010-03-01 01:49:08 +08:00
|
|
|
return this.combinator.toCSS() + this.value;
|
2010-02-24 02:39:05 +08:00
|
|
|
};
|
|
|
|
|
2010-03-02 04:32:21 +08:00
|
|
|
tree.Combinator = function Combinator(value) {
|
2010-03-06 00:39:39 +08:00
|
|
|
if (value === ' ') {
|
|
|
|
this.value = ' ';
|
|
|
|
} else {
|
|
|
|
this.value = value ? value.trim() : "";
|
|
|
|
}
|
2010-02-24 02:39:05 +08:00
|
|
|
};
|
2010-03-02 04:32:21 +08:00
|
|
|
tree.Combinator.prototype.toCSS = function () {
|
2010-02-24 02:39:05 +08:00
|
|
|
switch (this.value) {
|
2010-03-06 00:39:39 +08:00
|
|
|
case '' : return '';
|
|
|
|
case ' ' : return ' ';
|
2010-03-02 08:47:32 +08:00
|
|
|
case '&' : return '';
|
|
|
|
case ':' : return ' :';
|
2010-03-01 01:49:08 +08:00
|
|
|
case '::': return '::';
|
2010-03-02 08:47:32 +08:00
|
|
|
case '+' : return ' + ';
|
|
|
|
case '~' : return ' ~ ';
|
|
|
|
case '>' : return ' > ';
|
2010-02-24 02:39:05 +08:00
|
|
|
}
|
|
|
|
};
|