tizen beta release
[framework/web/web-ui-fw.git] / build-tools / lib / less / tree / element.js
1 (function (tree) {
2
3 tree.Element = function (combinator, value) {
4     this.combinator = combinator instanceof tree.Combinator ?
5                       combinator : new(tree.Combinator)(combinator);
6     this.value = value ? value.trim() : "";
7 };
8 tree.Element.prototype.toCSS = function (env) {
9     return this.combinator.toCSS(env || {}) + this.value;
10 };
11
12 tree.Combinator = function (value) {
13     if (value === ' ') {
14         this.value = ' ';
15     } else if (value === '& ') {
16         this.value = '& ';
17     } else {
18         this.value = value ? value.trim() : "";
19     }
20 };
21 tree.Combinator.prototype.toCSS = function (env) {
22     return {
23         ''  : '',
24         ' ' : ' ',
25         '&' : '',
26         '& ' : ' ',
27         ':' : ' :',
28         '::': '::',
29         '+' : env.compress ? '+' : ' + ',
30         '~' : env.compress ? '~' : ' ~ ',
31         '>' : env.compress ? '>' : ' > '
32     }[this.value];
33 };
34
35 })(require('less/tree'));