less 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/less/js/.gitignore +7 -0
- data/lib/less/js/.npmignore +1 -0
- data/lib/less/js/CHANGELOG.md +118 -0
- data/lib/less/js/CONTRIBUTING.md +50 -0
- data/lib/less/js/Makefile +14 -2
- data/lib/less/js/bin/lessc +72 -21
- data/lib/less/js/dist/less-1.3.1.js +4011 -0
- data/lib/less/js/dist/less-1.3.1.min.js +9 -0
- data/lib/less/js/dist/less-1.3.2.js +4401 -0
- data/lib/less/js/dist/less-1.3.2.min.js +9 -0
- data/lib/less/js/dist/less-1.3.3.js +4413 -0
- data/lib/less/js/dist/less-1.3.3.min.js +9 -0
- data/lib/less/js/dist/less-rhino-1.3.1.js +3725 -0
- data/lib/less/js/dist/less-rhino-1.3.2.js +3990 -0
- data/lib/less/js/dist/less-rhino-1.3.3.js +4002 -0
- data/lib/less/js/lib/less/browser.js +192 -53
- data/lib/less/js/lib/less/colors.js +1 -0
- data/lib/less/js/lib/less/functions.js +159 -10
- data/lib/less/js/lib/less/index.js +124 -56
- data/lib/less/js/lib/less/lessc_helper.js +62 -0
- data/lib/less/js/lib/less/parser.js +352 -135
- data/lib/less/js/lib/less/rhino.js +84 -23
- data/lib/less/js/lib/less/tree.js +28 -0
- data/lib/less/js/lib/less/tree/anonymous.js +15 -1
- data/lib/less/js/lib/less/tree/assignment.js +3 -1
- data/lib/less/js/lib/less/tree/call.js +12 -6
- data/lib/less/js/lib/less/tree/color.js +10 -0
- data/lib/less/js/lib/less/tree/dimension.js +3 -1
- data/lib/less/js/lib/less/tree/directive.js +9 -5
- data/lib/less/js/lib/less/tree/element.js +8 -6
- data/lib/less/js/lib/less/tree/import.js +16 -13
- data/lib/less/js/lib/less/tree/media.js +16 -9
- data/lib/less/js/lib/less/tree/mixin.js +123 -46
- data/lib/less/js/lib/less/tree/operation.js +5 -0
- data/lib/less/js/lib/less/tree/quoted.js +15 -1
- data/lib/less/js/lib/less/tree/ratio.js +13 -0
- data/lib/less/js/lib/less/tree/rule.js +7 -0
- data/lib/less/js/lib/less/tree/ruleset.js +232 -34
- data/lib/less/js/lib/less/tree/selector.js +21 -11
- data/lib/less/js/lib/less/tree/unicode-descriptor.js +13 -0
- data/lib/less/js/lib/less/tree/url.js +16 -14
- data/lib/less/js/lib/less/tree/variable.js +13 -1
- data/lib/less/js/package.json +13 -3
- data/lib/less/js/test/browser-test-prepare.js +29 -0
- data/lib/less/js/test/browser/common.js +74 -0
- data/lib/less/js/test/browser/css/relative-urls/urls.css +36 -0
- data/lib/less/js/test/browser/css/rootpath-relative/urls.css +36 -0
- data/lib/less/js/test/browser/css/rootpath/urls.css +36 -0
- data/lib/less/js/test/browser/css/urls.css +36 -0
- data/lib/less/js/test/browser/jasmine-html.js +681 -0
- data/lib/less/js/test/browser/jasmine.css +82 -0
- data/lib/less/js/test/browser/jasmine.js +2600 -0
- data/lib/less/js/test/browser/less/imports/urls.less +4 -0
- data/lib/less/js/test/browser/less/imports/urls2.less +4 -0
- data/lib/less/js/test/browser/less/relative-urls/urls.less +33 -0
- data/lib/less/js/test/browser/less/rootpath-relative/urls.less +33 -0
- data/lib/less/js/test/browser/less/rootpath/urls.less +33 -0
- data/lib/less/js/test/browser/less/urls.less +33 -0
- data/lib/less/js/test/browser/phantom-runner.js +139 -0
- data/lib/less/js/test/browser/runner-browser.js +3 -0
- data/lib/less/js/test/browser/runner-main.js +15 -0
- data/lib/less/js/test/browser/runner-relative-urls.js +4 -0
- data/lib/less/js/test/browser/runner-rootpath-relative.js +5 -0
- data/lib/less/js/test/browser/runner-rootpath.js +4 -0
- data/lib/less/js/test/browser/template.htm +10 -0
- data/lib/less/js/test/css/charsets.css +1 -0
- data/lib/less/js/test/css/colors.css +22 -0
- data/lib/less/js/test/css/comments.css +7 -0
- data/lib/less/js/test/css/css-3.css +57 -2
- data/lib/less/js/test/css/css-escapes.css +4 -0
- data/lib/less/js/test/css/css.css +11 -11
- data/lib/less/js/test/css/debug/linenumbers-all.css +43 -0
- data/lib/less/js/test/css/debug/linenumbers-comments.css +35 -0
- data/lib/less/js/test/css/debug/linenumbers-mediaquery.css +35 -0
- data/lib/less/js/test/css/functions.css +59 -2
- data/lib/less/js/test/css/ie-filters.css +7 -3
- data/lib/less/js/test/css/import-once.css +3 -0
- data/lib/less/js/test/css/import.css +7 -9
- data/lib/less/js/test/css/javascript.css +3 -2
- data/lib/less/js/test/css/media.css +116 -0
- data/lib/less/js/test/css/mixins-args.css +23 -4
- data/lib/less/js/test/css/mixins-guards.css +13 -0
- data/lib/less/js/test/css/mixins-important.css +21 -0
- data/lib/less/js/test/css/mixins-named-args.css +27 -0
- data/lib/less/js/test/css/mixins.css +50 -0
- data/lib/less/js/test/css/scope.css +20 -0
- data/lib/less/js/test/css/selectors.css +64 -0
- data/lib/less/js/test/css/static-urls/urls.css +42 -0
- data/lib/less/js/test/css/strings.css +2 -2
- data/lib/less/js/test/css/urls.css +42 -0
- data/lib/less/js/test/css/variables.css +0 -1
- data/lib/less/js/test/css/whitespace.css +4 -0
- data/lib/less/js/test/less-test.js +145 -36
- data/lib/less/js/test/less/charsets.less +3 -0
- data/lib/less/js/test/less/colors.less +27 -0
- data/lib/less/js/test/less/comments.less +12 -0
- data/lib/less/js/test/less/css-3.less +54 -6
- data/lib/less/js/test/less/css-escapes.less +6 -1
- data/lib/less/js/test/less/css.less +14 -12
- data/lib/less/js/test/less/debug/import/test.less +25 -0
- data/lib/less/js/test/less/debug/linenumbers.less +23 -0
- data/lib/less/js/test/less/errors/bad-variable-declaration1.less +1 -0
- data/lib/less/js/test/less/errors/bad-variable-declaration1.txt +2 -0
- data/lib/less/js/test/less/errors/comment-in-selector.less +1 -0
- data/lib/less/js/test/less/errors/comment-in-selector.txt +2 -0
- data/lib/less/js/test/less/errors/import-missing.less +1 -0
- data/lib/less/js/test/less/errors/import-missing.txt +3 -0
- data/lib/less/js/test/less/errors/import-no-semi.less +1 -0
- data/lib/less/js/test/less/errors/import-no-semi.txt +2 -0
- data/lib/less/js/test/less/errors/import-subfolder1.less +1 -0
- data/lib/less/js/test/less/errors/import-subfolder1.txt +3 -0
- data/lib/less/js/test/less/errors/import-subfolder2.less +1 -0
- data/lib/less/js/test/less/errors/import-subfolder2.txt +2 -0
- data/lib/less/js/test/less/errors/imports/import-subfolder1.less +1 -0
- data/lib/less/js/test/less/errors/imports/import-subfolder2.less +1 -0
- data/lib/less/js/test/less/errors/imports/import-test.less +4 -0
- data/lib/less/js/test/less/errors/imports/subfolder/mixin-not-defined.less +1 -0
- data/lib/less/js/test/less/errors/imports/subfolder/parse-error-curly-bracket.less +1 -0
- data/lib/less/js/test/less/errors/javascript-error.less +3 -0
- data/lib/less/js/test/less/errors/javascript-error.txt +4 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-1.less +6 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-1.txt +4 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-2.less +6 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-2.txt +4 -0
- data/lib/less/js/test/less/errors/mixin-not-defined.less +11 -0
- data/lib/less/js/test/less/errors/mixin-not-defined.txt +3 -0
- data/lib/less/js/test/less/errors/mixin-not-matched.less +6 -0
- data/lib/less/js/test/less/errors/mixin-not-matched.txt +3 -0
- data/lib/less/js/test/less/errors/mixin-not-matched2.less +6 -0
- data/lib/less/js/test/less/errors/mixin-not-matched2.txt +3 -0
- data/lib/less/js/test/less/errors/parse-error-curly-bracket.less +1 -0
- data/lib/less/js/test/less/errors/parse-error-curly-bracket.txt +2 -0
- data/lib/less/js/test/less/errors/parse-error-missing-bracket.less +2 -0
- data/lib/less/js/test/less/errors/parse-error-missing-bracket.txt +2 -0
- data/lib/less/js/test/less/errors/parse-error-with-import.less +13 -0
- data/lib/less/js/test/less/errors/parse-error-with-import.txt +4 -0
- data/lib/less/js/test/less/errors/property-ie5-hack.less +3 -0
- data/lib/less/js/test/less/errors/property-ie5-hack.txt +4 -0
- data/lib/less/js/test/less/errors/recursive-variable.less +1 -0
- data/lib/less/js/test/less/errors/recursive-variable.txt +2 -0
- data/lib/less/js/test/less/functions.less +64 -2
- data/lib/less/js/test/less/ie-filters.less +7 -0
- data/lib/less/js/test/less/import-once.less +4 -0
- data/lib/less/js/test/less/import.less +2 -1
- data/lib/less/js/test/less/import/deeper/import-once-test-a.less +1 -0
- data/lib/less/js/test/less/import/import-and-relative-paths-test.less +6 -0
- data/lib/less/js/test/less/import/import-charset-test.less +1 -0
- data/lib/less/js/test/less/import/import-once-test-c.less +6 -0
- data/lib/less/js/test/less/import/import-test-a.less +1 -0
- data/lib/less/js/test/less/import/import-test-c.less +0 -1
- data/lib/less/js/test/less/import/imports/font.less +8 -0
- data/lib/less/js/test/less/import/imports/logo.less +5 -0
- data/lib/less/js/test/less/import/urls.less +1 -0
- data/lib/less/js/test/less/javascript.less +4 -2
- data/lib/less/js/test/less/media.less +120 -0
- data/lib/less/js/test/less/mixins-args.less +40 -10
- data/lib/less/js/test/less/mixins-guards.less +30 -0
- data/lib/less/js/test/less/mixins-important.less +4 -0
- data/lib/less/js/test/less/mixins-named-args.less +36 -0
- data/lib/less/js/test/less/mixins.less +47 -0
- data/lib/less/js/test/less/scope.less +48 -1
- data/lib/less/js/test/less/selectors.less +81 -0
- data/lib/less/js/test/less/static-urls/urls.less +33 -0
- data/lib/less/js/test/less/strings.less +1 -1
- data/lib/less/js/test/less/urls.less +33 -0
- data/lib/less/js/test/less/variables.less +0 -1
- data/lib/less/js/test/less/whitespace.less +7 -0
- data/lib/less/version.rb +1 -1
- metadata +101 -4
- data/lib/less/js/CHANGELOG +0 -41
- data/lib/less/js/lib/less/cssmin.js +0 -355
@@ -1,20 +1,27 @@
|
|
1
1
|
var name;
|
2
2
|
|
3
3
|
function loadStyleSheet(sheet, callback, reload, remaining) {
|
4
|
-
var
|
5
|
-
|
4
|
+
var endOfPath = Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\')),
|
5
|
+
sheetName = name.slice(0, endOfPath + 1) + sheet.href,
|
6
|
+
contents = sheet.contents || {},
|
7
|
+
input = readFile(sheetName);
|
8
|
+
|
9
|
+
contents[sheetName] = input;
|
10
|
+
|
6
11
|
var parser = new less.Parser({
|
7
|
-
paths: [sheet.href.replace(/[\w\.-]+$/, '')]
|
12
|
+
paths: [sheet.href.replace(/[\w\.-]+$/, '')],
|
13
|
+
contents: contents
|
8
14
|
});
|
9
15
|
parser.parse(input, function (e, root) {
|
10
16
|
if (e) {
|
11
|
-
|
12
|
-
|
17
|
+
return error(e, sheetName);
|
18
|
+
}
|
19
|
+
try {
|
20
|
+
callback(e, root, input, sheet, { local: false, lastModified: 0, remaining: remaining }, sheetName);
|
21
|
+
} catch(e) {
|
22
|
+
error(e, sheetName);
|
13
23
|
}
|
14
|
-
callback(root, sheet, { local: false, lastModified: 0, remaining: remaining });
|
15
24
|
});
|
16
|
-
|
17
|
-
// callback({}, sheet, { local: true, remaining: remaining });
|
18
25
|
}
|
19
26
|
|
20
27
|
function writeFile(filename, content) {
|
@@ -26,8 +33,26 @@ function writeFile(filename, content) {
|
|
26
33
|
|
27
34
|
// Command line integration via Rhino
|
28
35
|
(function (args) {
|
29
|
-
|
30
|
-
|
36
|
+
var output,
|
37
|
+
compress = false,
|
38
|
+
i;
|
39
|
+
|
40
|
+
for(i = 0; i < args.length; i++) {
|
41
|
+
switch(args[i]) {
|
42
|
+
case "-x":
|
43
|
+
compress = true;
|
44
|
+
break;
|
45
|
+
default:
|
46
|
+
if (!name) {
|
47
|
+
name = args[i];
|
48
|
+
} else if (!output) {
|
49
|
+
output = args[i];
|
50
|
+
} else {
|
51
|
+
print("unrecognised parameters");
|
52
|
+
print("input_file [output_file] [-x]");
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
31
56
|
|
32
57
|
if (!name) {
|
33
58
|
print('No files present in the fileset; Check your pattern match in build.xml');
|
@@ -43,20 +68,56 @@ function writeFile(filename, content) {
|
|
43
68
|
}
|
44
69
|
|
45
70
|
var result;
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
if (output) {
|
53
|
-
writeFile(output, result);
|
54
|
-
print("Written to " + output);
|
71
|
+
try {
|
72
|
+
var parser = new less.Parser();
|
73
|
+
parser.parse(input, function (e, root) {
|
74
|
+
if (e) {
|
75
|
+
error(e, name);
|
76
|
+
quit(1);
|
55
77
|
} else {
|
56
|
-
|
78
|
+
result = root.toCSS({compress: compress || false});
|
79
|
+
if (output) {
|
80
|
+
writeFile(output, result);
|
81
|
+
print("Written to " + output);
|
82
|
+
} else {
|
83
|
+
print(result);
|
84
|
+
}
|
85
|
+
quit(0);
|
57
86
|
}
|
58
|
-
|
59
|
-
|
60
|
-
|
87
|
+
});
|
88
|
+
}
|
89
|
+
catch(e) {
|
90
|
+
error(e, name);
|
91
|
+
quit(1);
|
92
|
+
}
|
61
93
|
print("done");
|
62
94
|
}(arguments));
|
95
|
+
|
96
|
+
function error(e, filename) {
|
97
|
+
|
98
|
+
var content = "Error : " + filename + "\n";
|
99
|
+
|
100
|
+
filename = e.filename || filename;
|
101
|
+
|
102
|
+
if (e.message) {
|
103
|
+
content += e.message + "\n";
|
104
|
+
}
|
105
|
+
|
106
|
+
var errorline = function (e, i, classname) {
|
107
|
+
if (e.extract[i]) {
|
108
|
+
content +=
|
109
|
+
String(parseInt(e.line) + (i - 1)) +
|
110
|
+
":" + e.extract[i] + "\n";
|
111
|
+
}
|
112
|
+
};
|
113
|
+
|
114
|
+
if (e.stack) {
|
115
|
+
content += e.stack;
|
116
|
+
} else if (e.extract) {
|
117
|
+
content += 'on line ' + e.line + ', column ' + (e.column + 1) + ':\n';
|
118
|
+
errorline(e, 0);
|
119
|
+
errorline(e, 1);
|
120
|
+
errorline(e, 2);
|
121
|
+
}
|
122
|
+
print(content);
|
123
|
+
}
|
@@ -1,5 +1,33 @@
|
|
1
1
|
(function (tree) {
|
2
2
|
|
3
|
+
tree.debugInfo = function(env, ctx) {
|
4
|
+
var result="";
|
5
|
+
if (env.dumpLineNumbers && !env.compress) {
|
6
|
+
switch(env.dumpLineNumbers) {
|
7
|
+
case 'comments':
|
8
|
+
result = tree.debugInfo.asComment(ctx);
|
9
|
+
break;
|
10
|
+
case 'mediaquery':
|
11
|
+
result = tree.debugInfo.asMediaQuery(ctx);
|
12
|
+
break;
|
13
|
+
case 'all':
|
14
|
+
result = tree.debugInfo.asComment(ctx)+tree.debugInfo.asMediaQuery(ctx);
|
15
|
+
break;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
return result;
|
19
|
+
};
|
20
|
+
|
21
|
+
tree.debugInfo.asComment = function(ctx) {
|
22
|
+
return '/* line ' + ctx.debugInfo.lineNumber + ', ' + ctx.debugInfo.fileName + ' */\n';
|
23
|
+
};
|
24
|
+
|
25
|
+
tree.debugInfo.asMediaQuery = function(ctx) {
|
26
|
+
return '@media -sass-debug-info{filename{font-family:' +
|
27
|
+
('file://' + ctx.debugInfo.fileName).replace(/[\/:.]/g, '\\$&') +
|
28
|
+
'}line{font-family:\\00003' + ctx.debugInfo.lineNumber + '}}\n';
|
29
|
+
};
|
30
|
+
|
3
31
|
tree.find = function (obj, fun) {
|
4
32
|
for (var i = 0, r; i < obj.length; i++) {
|
5
33
|
if (r = fun.call(obj, obj[i])) { return r }
|
@@ -7,7 +7,21 @@ tree.Anonymous.prototype = {
|
|
7
7
|
toCSS: function () {
|
8
8
|
return this.value;
|
9
9
|
},
|
10
|
-
eval: function () { return this }
|
10
|
+
eval: function () { return this },
|
11
|
+
compare: function (x) {
|
12
|
+
if (!x.toCSS) {
|
13
|
+
return -1;
|
14
|
+
}
|
15
|
+
|
16
|
+
var left = this.toCSS(),
|
17
|
+
right = x.toCSS();
|
18
|
+
|
19
|
+
if (left === right) {
|
20
|
+
return 0;
|
21
|
+
}
|
22
|
+
|
23
|
+
return left < right ? -1 : 1;
|
24
|
+
}
|
11
25
|
};
|
12
26
|
|
13
27
|
})(require('../tree'));
|
@@ -9,7 +9,9 @@ tree.Assignment.prototype = {
|
|
9
9
|
return this.key + '=' + (this.value.toCSS ? this.value.toCSS() : this.value);
|
10
10
|
},
|
11
11
|
eval: function (env) {
|
12
|
-
if (this.value.eval) {
|
12
|
+
if (this.value.eval) {
|
13
|
+
return new(tree.Assignment)(this.key, this.value.eval(env));
|
14
|
+
}
|
13
15
|
return this;
|
14
16
|
}
|
15
17
|
};
|
@@ -14,7 +14,8 @@ tree.Call.prototype = {
|
|
14
14
|
// When evaluating a function call,
|
15
15
|
// we either find the function in `tree.functions` [1],
|
16
16
|
// in which case we call it, passing the evaluated arguments,
|
17
|
-
//
|
17
|
+
// if this returns null or we cannot find the function, we
|
18
|
+
// simply print it out as it appeared originally [2].
|
18
19
|
//
|
19
20
|
// The *functions.js* file contains the built-in functions.
|
20
21
|
//
|
@@ -23,21 +24,26 @@ tree.Call.prototype = {
|
|
23
24
|
// The function should receive the value, not the variable.
|
24
25
|
//
|
25
26
|
eval: function (env) {
|
26
|
-
var args = this.args.map(function (a) { return a.eval(env) })
|
27
|
+
var args = this.args.map(function (a) { return a.eval(env) }),
|
28
|
+
result;
|
27
29
|
|
28
30
|
if (this.name in tree.functions) { // 1.
|
29
31
|
try {
|
30
|
-
|
32
|
+
result = tree.functions[this.name].apply(tree.functions, args);
|
33
|
+
if (result != null) {
|
34
|
+
return result;
|
35
|
+
}
|
31
36
|
} catch (e) {
|
32
37
|
throw { type: e.type || "Runtime",
|
33
38
|
message: "error evaluating function `" + this.name + "`" +
|
34
39
|
(e.message ? ': ' + e.message : ''),
|
35
40
|
index: this.index, filename: this.filename };
|
36
41
|
}
|
37
|
-
} else { // 2.
|
38
|
-
return new(tree.Anonymous)(this.name +
|
39
|
-
"(" + args.map(function (a) { return a.toCSS() }).join(', ') + ")");
|
40
42
|
}
|
43
|
+
|
44
|
+
// 2.
|
45
|
+
return new(tree.Anonymous)(this.name +
|
46
|
+
"(" + args.map(function (a) { return a.toCSS(env) }).join(', ') + ")");
|
41
47
|
},
|
42
48
|
|
43
49
|
toCSS: function (env) {
|
@@ -94,6 +94,16 @@ tree.Color.prototype = {
|
|
94
94
|
i = (i > 255 ? 255 : (i < 0 ? 0 : i)).toString(16);
|
95
95
|
return i.length === 1 ? '0' + i : i;
|
96
96
|
}).join('');
|
97
|
+
},
|
98
|
+
compare: function (x) {
|
99
|
+
if (!x.rgb) {
|
100
|
+
return -1;
|
101
|
+
}
|
102
|
+
|
103
|
+
return (x.rgb[0] === this.rgb[0] &&
|
104
|
+
x.rgb[1] === this.rgb[1] &&
|
105
|
+
x.rgb[2] === this.rgb[2] &&
|
106
|
+
x.alpha === this.alpha) ? 0 : -1;
|
97
107
|
}
|
98
108
|
};
|
99
109
|
|
@@ -30,7 +30,6 @@ tree.Dimension.prototype = {
|
|
30
30
|
this.unit || other.unit);
|
31
31
|
},
|
32
32
|
|
33
|
-
// TODO: Perform unit conversion before comparing
|
34
33
|
compare: function (other) {
|
35
34
|
if (other instanceof tree.Dimension) {
|
36
35
|
if (other.value > this.value) {
|
@@ -38,6 +37,9 @@ tree.Dimension.prototype = {
|
|
38
37
|
} else if (other.value < this.value) {
|
39
38
|
return 1;
|
40
39
|
} else {
|
40
|
+
if (other.unit && this.unit !== other.unit) {
|
41
|
+
return -1;
|
42
|
+
}
|
41
43
|
return 0;
|
42
44
|
}
|
43
45
|
} else {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
(function (tree) {
|
2
2
|
|
3
|
-
tree.Directive = function (name, value
|
3
|
+
tree.Directive = function (name, value) {
|
4
4
|
this.name = name;
|
5
5
|
|
6
6
|
if (Array.isArray(value)) {
|
@@ -22,10 +22,14 @@ tree.Directive.prototype = {
|
|
22
22
|
}
|
23
23
|
},
|
24
24
|
eval: function (env) {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
var evaldDirective = this;
|
26
|
+
if (this.ruleset) {
|
27
|
+
env.frames.unshift(this);
|
28
|
+
evaldDirective = new(tree.Directive)(this.name);
|
29
|
+
evaldDirective.ruleset = this.ruleset.eval(env);
|
30
|
+
env.frames.shift();
|
31
|
+
}
|
32
|
+
return evaldDirective;
|
29
33
|
},
|
30
34
|
variable: function (name) { return tree.Ruleset.prototype.variable.call(this.ruleset, name) },
|
31
35
|
find: function () { return tree.Ruleset.prototype.find.apply(this.ruleset, arguments) },
|
@@ -19,14 +19,17 @@ tree.Element.prototype.eval = function (env) {
|
|
19
19
|
this.index);
|
20
20
|
};
|
21
21
|
tree.Element.prototype.toCSS = function (env) {
|
22
|
-
|
22
|
+
var value = (this.value.toCSS ? this.value.toCSS(env) : this.value);
|
23
|
+
if (value == '' && this.combinator.value.charAt(0) == '&') {
|
24
|
+
return '';
|
25
|
+
} else {
|
26
|
+
return this.combinator.toCSS(env || {}) + value;
|
27
|
+
}
|
23
28
|
};
|
24
29
|
|
25
30
|
tree.Combinator = function (value) {
|
26
31
|
if (value === ' ') {
|
27
32
|
this.value = ' ';
|
28
|
-
} else if (value === '& ') {
|
29
|
-
this.value = '& ';
|
30
33
|
} else {
|
31
34
|
this.value = value ? value.trim() : "";
|
32
35
|
}
|
@@ -35,12 +38,11 @@ tree.Combinator.prototype.toCSS = function (env) {
|
|
35
38
|
return {
|
36
39
|
'' : '',
|
37
40
|
' ' : ' ',
|
38
|
-
'&' : '',
|
39
|
-
'& ' : ' ',
|
40
41
|
':' : ' :',
|
41
42
|
'+' : env.compress ? '+' : ' + ',
|
42
43
|
'~' : env.compress ? '~' : ' ~ ',
|
43
|
-
'>' : env.compress ? '>' : ' > '
|
44
|
+
'>' : env.compress ? '>' : ' > ',
|
45
|
+
'|' : env.compress ? '|' : ' | '
|
44
46
|
}[this.value];
|
45
47
|
};
|
46
48
|
|
@@ -11,26 +11,29 @@
|
|
11
11
|
// `import,push`, we also pass it a callback, which it'll call once
|
12
12
|
// the file has been fetched, and parsed.
|
13
13
|
//
|
14
|
-
tree.Import = function (path, imports, features, index) {
|
14
|
+
tree.Import = function (path, imports, features, once, index, rootpath) {
|
15
15
|
var that = this;
|
16
16
|
|
17
|
+
this.once = once;
|
17
18
|
this.index = index;
|
18
19
|
this._path = path;
|
19
20
|
this.features = features && new(tree.Value)(features);
|
20
|
-
|
21
|
+
this.rootpath = rootpath;
|
22
|
+
|
21
23
|
// The '.less' extension is optional
|
22
24
|
if (path instanceof tree.Quoted) {
|
23
|
-
this.path =
|
25
|
+
this.path = /(\.[a-z]*$)|([\?;].*)$/.test(path.value) ? path.value : path.value + '.less';
|
24
26
|
} else {
|
25
27
|
this.path = path.value.value || path.value;
|
26
28
|
}
|
27
29
|
|
28
|
-
this.css = /css(
|
30
|
+
this.css = /css([\?;].*)?$/.test(this.path);
|
29
31
|
|
30
32
|
// Only pre-compile .less files
|
31
33
|
if (! this.css) {
|
32
|
-
imports.push(this.path, function (e, root) {
|
34
|
+
imports.push(this.path, function (e, root, imported) {
|
33
35
|
if (e) { e.index = index }
|
36
|
+
if (imported && that.once) that.skip = imported;
|
34
37
|
that.root = root || new(tree.Ruleset)([], []);
|
35
38
|
});
|
36
39
|
}
|
@@ -50,6 +53,10 @@ tree.Import.prototype = {
|
|
50
53
|
var features = this.features ? ' ' + this.features.toCSS(env) : '';
|
51
54
|
|
52
55
|
if (this.css) {
|
56
|
+
// Add the base path if the import is relative
|
57
|
+
if (typeof this._path.value === "string" && !/^(?:[a-z-]+:|\/)/.test(this._path.value)) {
|
58
|
+
this._path.value = this.rootpath + this._path.value;
|
59
|
+
}
|
53
60
|
return "@import " + this._path.toCSS() + features + ';\n';
|
54
61
|
} else {
|
55
62
|
return "";
|
@@ -58,19 +65,15 @@ tree.Import.prototype = {
|
|
58
65
|
eval: function (env) {
|
59
66
|
var ruleset, features = this.features && this.features.eval(env);
|
60
67
|
|
68
|
+
if (this.skip) return [];
|
69
|
+
|
61
70
|
if (this.css) {
|
62
71
|
return this;
|
63
72
|
} else {
|
64
73
|
ruleset = new(tree.Ruleset)([], this.root.rules.slice(0));
|
65
74
|
|
66
|
-
|
67
|
-
|
68
|
-
Array.prototype
|
69
|
-
.splice
|
70
|
-
.apply(ruleset.rules,
|
71
|
-
[i, 1].concat(ruleset.rules[i].eval(env)));
|
72
|
-
}
|
73
|
-
}
|
75
|
+
ruleset.evalImports(env);
|
76
|
+
|
74
77
|
return this.features ? new(tree.Media)(ruleset.rules, this.features.value) : ruleset.rules;
|
75
78
|
}
|
76
79
|
}
|
@@ -1,8 +1,7 @@
|
|
1
1
|
(function (tree) {
|
2
2
|
|
3
3
|
tree.Media = function (value, features) {
|
4
|
-
var
|
5
|
-
selectors = [new(tree.Selector)([el])];
|
4
|
+
var selectors = this.emptySelectors();
|
6
5
|
|
7
6
|
this.features = new(tree.Value)(features);
|
8
7
|
this.ruleset = new(tree.Ruleset)(selectors, value);
|
@@ -23,18 +22,20 @@ tree.Media.prototype = {
|
|
23
22
|
env.mediaPath = [];
|
24
23
|
}
|
25
24
|
|
26
|
-
var blockIndex = env.mediaBlocks.length;
|
27
|
-
env.mediaPath.push(this);
|
28
|
-
env.mediaBlocks.push(this);
|
29
|
-
|
30
25
|
var media = new(tree.Media)([], []);
|
26
|
+
if(this.debugInfo) {
|
27
|
+
this.ruleset.debugInfo = this.debugInfo;
|
28
|
+
media.debugInfo = this.debugInfo;
|
29
|
+
}
|
31
30
|
media.features = this.features.eval(env);
|
32
31
|
|
32
|
+
env.mediaPath.push(media);
|
33
|
+
env.mediaBlocks.push(media);
|
34
|
+
|
33
35
|
env.frames.unshift(this.ruleset);
|
34
36
|
media.ruleset = this.ruleset.eval(env);
|
35
37
|
env.frames.shift();
|
36
38
|
|
37
|
-
env.mediaBlocks[blockIndex] = media;
|
38
39
|
env.mediaPath.pop();
|
39
40
|
|
40
41
|
return env.mediaPath.length === 0 ? media.evalTop(env) :
|
@@ -43,14 +44,17 @@ tree.Media.prototype = {
|
|
43
44
|
variable: function (name) { return tree.Ruleset.prototype.variable.call(this.ruleset, name) },
|
44
45
|
find: function () { return tree.Ruleset.prototype.find.apply(this.ruleset, arguments) },
|
45
46
|
rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.ruleset) },
|
47
|
+
emptySelectors: function() {
|
48
|
+
var el = new(tree.Element)('', '&', 0);
|
49
|
+
return [new(tree.Selector)([el])];
|
50
|
+
},
|
46
51
|
|
47
52
|
evalTop: function (env) {
|
48
53
|
var result = this;
|
49
54
|
|
50
55
|
// Render all dependent Media blocks.
|
51
56
|
if (env.mediaBlocks.length > 1) {
|
52
|
-
var
|
53
|
-
var selectors = [new(tree.Selector)([el])];
|
57
|
+
var selectors = this.emptySelectors();
|
54
58
|
result = new(tree.Ruleset)(selectors, env.mediaBlocks);
|
55
59
|
result.multiMedia = true;
|
56
60
|
}
|
@@ -108,6 +112,9 @@ tree.Media.prototype = {
|
|
108
112
|
}
|
109
113
|
return result;
|
110
114
|
}
|
115
|
+
},
|
116
|
+
bubbleSelectors: function (selectors) {
|
117
|
+
this.ruleset = new(tree.Ruleset)(selectors.slice(0), [this.ruleset]);
|
111
118
|
}
|
112
119
|
};
|
113
120
|
|