build-tools : upgrade less to v1.3.3
[platform/framework/web/web-ui-fw.git] / build-tools / lib / less / tree / element.js
index 27cf822..4e251ee 100644 (file)
@@ -1,19 +1,35 @@
 (function (tree) {
 
-tree.Element = function (combinator, value) {
+tree.Element = function (combinator, value, index) {
     this.combinator = combinator instanceof tree.Combinator ?
                       combinator : new(tree.Combinator)(combinator);
-    this.value = value ? value.trim() : "";
+
+    if (typeof(value) === 'string') {
+        this.value = value.trim();
+    } else if (value) {
+        this.value = value;
+    } else {
+        this.value = "";
+    }
+    this.index = index;
+};
+tree.Element.prototype.eval = function (env) {
+    return new(tree.Element)(this.combinator,
+                             this.value.eval ? this.value.eval(env) : this.value,
+                             this.index);
 };
 tree.Element.prototype.toCSS = function (env) {
-    return this.combinator.toCSS(env || {}) + this.value;
+       var value = (this.value.toCSS ? this.value.toCSS(env) : this.value);
+       if (value == '' && this.combinator.value.charAt(0) == '&') {
+               return '';
+       } else {
+               return this.combinator.toCSS(env || {}) + value;
+       }
 };
 
 tree.Combinator = function (value) {
     if (value === ' ') {
         this.value = ' ';
-    } else if (value === '& ') {
-        this.value = '& ';
     } else {
         this.value = value ? value.trim() : "";
     }
@@ -22,14 +38,12 @@ tree.Combinator.prototype.toCSS = function (env) {
     return {
         ''  : '',
         ' ' : ' ',
-        '&' : '',
-        '& ' : ' ',
         ':' : ' :',
-        '::': '::',
         '+' : env.compress ? '+' : ' + ',
         '~' : env.compress ? '~' : ' ~ ',
-        '>' : env.compress ? '>' : ' > '
+        '>' : env.compress ? '>' : ' > ',
+        '|' : env.compress ? '|' : ' | '
     }[this.value];
 };
 
-})(require('less/tree'));
+})(require('../tree'));