source: Dev/branches/rest-dojo-ui/client/util/less/tree/element.js @ 257

Last change on this file since 257 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

  • Property svn:executable set to *
File size: 925 bytes
Line 
1(function (tree) {
2
3tree.Element = function (combinator, value) {
4    this.combinator = combinator instanceof tree.Combinator ?
5                      combinator : new(tree.Combinator)(combinator);
6    this.value = value ? value.trim() : "";
7};
8tree.Element.prototype.toCSS = function (env) {
9    return this.combinator.toCSS(env || {}) + this.value;
10};
11
12tree.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};
21tree.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'));
Note: See TracBrowser for help on using the repository browser.