18cc49bfa63d07ca8e9c7d87e5ab37ec4271b48d
[platform/framework/web/web-ui-fw.git] / build-tools / lib / less / tree / rule.js
1 (function (tree) {
2
3 tree.Rule = function (name, value, important, index) {
4     this.name = name;
5     this.value = (value instanceof tree.Value) ? value : new(tree.Value)([value]);
6     this.important = important ? ' ' + important.trim() : '';
7     this.index = index;
8
9     if (name.charAt(0) === '@') {
10         this.variable = true;
11     } else { this.variable = false }
12 };
13 tree.Rule.prototype.toCSS = function (env) {
14     if (this.variable) { return "" }
15     else {
16         return this.name + (env.compress ? ':' : ': ') +
17                this.value.toCSS(env) +
18                this.important + ";";
19     }
20 };
21
22 tree.Rule.prototype.eval = function (context) {
23     return new(tree.Rule)(this.name, this.value.eval(context), this.important, this.index);
24 };
25
26 tree.Shorthand = function (a, b) {
27     this.a = a;
28     this.b = b;
29 };
30
31 tree.Shorthand.prototype = {
32     toCSS: function (env) {
33         return this.a.toCSS(env) + "/" + this.b.toCSS(env);
34     },
35     eval: function () { return this }
36 };
37
38 })(require('less/tree'));