less 2.1.2 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/inspectionProfiles/Project_Default.xml +1 -0
- package/.idea/jsLinters/jscs.xml +4 -0
- package/.idea/jsLinters/jshint.xml +58 -4
- package/.idea/workspace.xml +499 -760
- package/.jscsrc +73 -0
- package/.jshintrc +0 -2
- package/.travis.yml +1 -0
- package/CHANGELOG.md +59 -0
- package/Gruntfile.js +37 -3
- package/appveyor.yml +5 -0
- package/bin/lessc +383 -316
- package/bower.json +1 -1
- package/dist/less.js +1638 -1244
- package/dist/less.min.js +7 -7
- package/lib/less/contexts.js +3 -3
- package/lib/less/data/unit-conversions.js +3 -3
- package/lib/less/environment/abstract-file-manager.js +8 -8
- package/lib/less/environment/environment.js +2 -2
- package/lib/less/functions/color-blending.js +3 -3
- package/lib/less/functions/color.js +20 -12
- package/lib/less/functions/data-uri.js +26 -18
- package/lib/less/functions/math.js +1 -1
- package/lib/less/functions/number.js +2 -2
- package/lib/less/functions/string.js +3 -1
- package/lib/less/functions/svg.js +12 -15
- package/lib/less/functions/types.js +33 -10
- package/lib/less/import-manager.js +14 -9
- package/lib/less/index.js +2 -1
- package/lib/less/less-error.js +1 -1
- package/lib/less/logger.js +2 -2
- package/lib/less/parse-tree.js +48 -42
- package/lib/less/parse.js +68 -0
- package/lib/less/parser/parser-input.js +6 -5
- package/lib/less/parser/parser.js +76 -29
- package/lib/less/plugin-manager.js +30 -3
- package/lib/less/render.js +11 -37
- package/lib/less/source-map-builder.js +4 -0
- package/lib/less/source-map-output.js +6 -6
- package/lib/less/transform-tree.js +4 -4
- package/lib/less/tree/anonymous.js +1 -1
- package/lib/less/tree/assignment.js +0 -1
- package/lib/less/tree/call.js +1 -1
- package/lib/less/tree/color.js +6 -6
- package/lib/less/tree/condition.js +9 -5
- package/lib/less/tree/debug-info.js +6 -2
- package/lib/less/tree/dimension.js +5 -5
- package/lib/less/tree/directive.js +25 -6
- package/lib/less/tree/element.js +1 -1
- package/lib/less/tree/expression.js +2 -2
- package/lib/less/tree/extend.js +3 -3
- package/lib/less/tree/import.js +2 -2
- package/lib/less/tree/index.js +1 -0
- package/lib/less/tree/javascript.js +2 -2
- package/lib/less/tree/media.js +20 -19
- package/lib/less/tree/mixin-call.js +5 -6
- package/lib/less/tree/mixin-definition.js +33 -11
- package/lib/less/tree/quoted.js +3 -3
- package/lib/less/tree/rule.js +3 -4
- package/lib/less/tree/ruleset.js +290 -177
- package/lib/less/tree/selector.js +3 -2
- package/lib/less/tree/unit.js +2 -0
- package/lib/less/tree/url.js +5 -2
- package/lib/less/tree/value.js +2 -2
- package/lib/less/tree/variable.js +1 -1
- package/lib/less/visitors/extend-visitor.js +72 -36
- package/lib/less/visitors/import-sequencer.js +20 -14
- package/lib/less/visitors/import-visitor.js +15 -12
- package/lib/less/visitors/to-css-visitor.js +41 -9
- package/lib/less-browser/add-default-options.js +5 -1
- package/lib/less-browser/bootstrap.js +10 -8
- package/lib/less-browser/cache.js +3 -3
- package/lib/less-browser/file-manager.js +96 -96
- package/lib/less-browser/index.js +206 -205
- package/lib/less-browser/log-listener.js +2 -2
- package/lib/less-browser/utils.js +6 -6
- package/lib/less-node/file-manager.js +58 -30
- package/lib/less-node/image-size.js +34 -0
- package/lib/less-node/index.js +6 -3
- package/lib/less-node/lessc-helper.js +3 -2
- package/lib/less-node/plugin-loader.js +3 -3
- package/lib/less-node/url-file-manager.js +6 -3
- package/lib/less-rhino/index.js +15 -13
- package/lib/source-map/source-map-0.1.31.js +1 -1
- package/package.json +10 -7
- package/test/browser/common.js +13 -11
- package/test/browser/css/relative-urls/urls.css +1 -0
- package/test/browser/css/urls.css +6 -3
- package/test/browser/jasmine-jsreporter.js +2 -3
- package/test/browser/less/nested-gradient-with-svg-gradient/mixin-consumer.less +5 -0
- package/test/browser/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +15 -0
- package/test/browser/less/relative-urls/urls.less +1 -0
- package/test/browser/less/urls.less +1 -0
- package/test/browser/runner-browser-options.js +23 -23
- package/test/browser/runner-errors-options.js +0 -1
- package/test/browser/runner-errors-spec.js +1 -2
- package/test/browser/runner-global-vars-spec.js +1 -1
- package/test/browser/runner-legacy-options.js +0 -1
- package/test/browser/runner-main-options.js +5 -5
- package/test/browser/runner-main-spec.js +1 -1
- package/test/browser/runner-no-js-errors-spec.js +0 -1
- package/test/browser/runner-production-options.js +0 -1
- package/test/browser/runner-relative-urls-options.js +0 -1
- package/test/browser/runner-rootpath-options.js +0 -1
- package/test/browser/runner-rootpath-relative-options.js +0 -1
- package/test/browser/runner-strict-units-options.js +0 -1
- package/test/copy-bom.js +72 -0
- package/test/css/comments.css +1 -0
- package/test/css/css-3.css +2 -0
- package/test/css/functions.css +10 -0
- package/test/css/import-interpolation.css +7 -0
- package/test/css/import-reference.css +25 -0
- package/test/css/include-path/include-path.css +6 -0
- package/test/css/mixins-important.css +12 -0
- package/test/css/selectors.css +15 -1
- package/test/css/static-urls/urls.css +1 -0
- package/test/css/url-args/urls.css +3 -3
- package/test/css/urls.css +13 -4
- package/test/css/variables.css +7 -1
- package/test/data/image.svg +3 -0
- package/test/index.js +15 -10
- package/test/less/comments.less +1 -0
- package/test/less/css-3.less +3 -0
- package/test/less/css-guards.less +2 -1
- package/test/less/errors/detached-ruleset-2.txt +1 -1
- package/test/less/errors/import-missing.txt +1 -1
- package/test/less/errors/parens-error-1.txt +1 -1
- package/test/less/errors/parens-error-2.txt +1 -1
- package/test/less/errors/parens-error-3.txt +1 -1
- package/test/less/errors/single-character.less +1 -0
- package/test/less/errors/single-character.txt +2 -0
- package/test/less/functions.less +18 -0
- package/test/less/import/import-interpolation.less +1 -0
- package/test/less/import/import-reference.less +38 -0
- package/test/less/import/imports/logo.less +1 -0
- package/test/less/import-reference.less +3 -1
- package/test/less/import.less +2 -0
- package/test/less/include-path/include-path.less +6 -0
- package/test/less/mixins-important.less +28 -0
- package/test/less/nested-gradient-with-svg-gradient/mixin-consumer.less +5 -0
- package/test/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +15 -0
- package/test/less/selectors.less +29 -4
- package/test/less/sourcemaps-empty/empty.less +0 -0
- package/test/less/sourcemaps-empty/var-defs.less +1 -0
- package/test/less/urls.less +10 -1
- package/test/less/variables.less +17 -3
- package/test/less-test.js +133 -52
- package/test/modify-vars.js +14 -12
- package/test/browser/less.js +0 -9473
|
@@ -2,118 +2,118 @@
|
|
|
2
2
|
|
|
3
3
|
module.exports = function(options, logger) {
|
|
4
4
|
|
|
5
|
-
var AbstractFileManager = require("../less/environment/abstract-file-manager.js");
|
|
6
|
-
|
|
7
|
-
var fileCache = {};
|
|
8
|
-
|
|
9
|
-
//TODOS - move log somewhere. pathDiff and doing something similar in node. use pathDiff in the other browser file for the initial load
|
|
10
|
-
|
|
11
|
-
function getXMLHttpRequest() {
|
|
12
|
-
if (window.XMLHttpRequest && (window.location.protocol !== "file:" || !("ActiveXObject" in window))) {
|
|
13
|
-
return new XMLHttpRequest();
|
|
14
|
-
} else {
|
|
15
|
-
try {
|
|
16
|
-
/*global ActiveXObject */
|
|
17
|
-
return new ActiveXObject("Microsoft.XMLHTTP");
|
|
18
|
-
} catch (e) {
|
|
19
|
-
logger.error("browser doesn't support AJAX.");
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
5
|
+
var AbstractFileManager = require("../less/environment/abstract-file-manager.js");
|
|
24
6
|
|
|
25
|
-
var
|
|
26
|
-
};
|
|
7
|
+
var fileCache = {};
|
|
27
8
|
|
|
28
|
-
|
|
9
|
+
//TODOS - move log somewhere. pathDiff and doing something similar in node. use pathDiff in the other browser file for the initial load
|
|
29
10
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
11
|
+
function getXMLHttpRequest() {
|
|
12
|
+
if (window.XMLHttpRequest && (window.location.protocol !== "file:" || !("ActiveXObject" in window))) {
|
|
13
|
+
return new XMLHttpRequest();
|
|
14
|
+
} else {
|
|
15
|
+
try {
|
|
16
|
+
/*global ActiveXObject */
|
|
17
|
+
return new ActiveXObject("Microsoft.XMLHTTP");
|
|
18
|
+
} catch (e) {
|
|
19
|
+
logger.error("browser doesn't support AJAX.");
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
36
23
|
}
|
|
37
|
-
return this.extractUrlParts(laterPath, basePath).path;
|
|
38
|
-
};
|
|
39
|
-
FileManager.prototype.doXHR = function doXHR(url, type, callback, errback) {
|
|
40
24
|
|
|
41
|
-
var
|
|
42
|
-
|
|
25
|
+
var FileManager = function() {
|
|
26
|
+
};
|
|
43
27
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
function handleResponse(xhr, callback, errback) {
|
|
53
|
-
if (xhr.status >= 200 && xhr.status < 300) {
|
|
54
|
-
callback(xhr.responseText,
|
|
55
|
-
xhr.getResponseHeader("Last-Modified"));
|
|
56
|
-
} else if (typeof(errback) === 'function') {
|
|
57
|
-
errback(xhr.status, url);
|
|
28
|
+
FileManager.prototype = new AbstractFileManager();
|
|
29
|
+
|
|
30
|
+
FileManager.prototype.alwaysMakePathsAbsolute = function alwaysMakePathsAbsolute() {
|
|
31
|
+
return true;
|
|
32
|
+
};
|
|
33
|
+
FileManager.prototype.join = function join(basePath, laterPath) {
|
|
34
|
+
if (!basePath) {
|
|
35
|
+
return laterPath;
|
|
58
36
|
}
|
|
59
|
-
|
|
37
|
+
return this.extractUrlParts(laterPath, basePath).path;
|
|
38
|
+
};
|
|
39
|
+
FileManager.prototype.doXHR = function doXHR(url, type, callback, errback) {
|
|
60
40
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
41
|
+
var xhr = getXMLHttpRequest();
|
|
42
|
+
var async = options.isFileProtocol ? options.fileAsync : options.async;
|
|
43
|
+
|
|
44
|
+
if (typeof xhr.overrideMimeType === 'function') {
|
|
45
|
+
xhr.overrideMimeType('text/css');
|
|
66
46
|
}
|
|
67
|
-
|
|
68
|
-
xhr.
|
|
69
|
-
|
|
70
|
-
|
|
47
|
+
logger.debug("XHR: Getting '" + url + "'");
|
|
48
|
+
xhr.open('GET', url, async);
|
|
49
|
+
xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5');
|
|
50
|
+
xhr.send(null);
|
|
51
|
+
|
|
52
|
+
function handleResponse(xhr, callback, errback) {
|
|
53
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
54
|
+
callback(xhr.responseText,
|
|
55
|
+
xhr.getResponseHeader("Last-Modified"));
|
|
56
|
+
} else if (typeof errback === 'function') {
|
|
57
|
+
errback(xhr.status, url);
|
|
71
58
|
}
|
|
72
|
-
}
|
|
73
|
-
} else {
|
|
74
|
-
handleResponse(xhr, callback, errback);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
FileManager.prototype.supports = function(filename, currentDirectory, options, environment) {
|
|
78
|
-
return true;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
FileManager.prototype.clearFileCache = function() {
|
|
82
|
-
fileCache = {};
|
|
83
|
-
};
|
|
59
|
+
}
|
|
84
60
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
61
|
+
if (options.isFileProtocol && !options.fileAsync) {
|
|
62
|
+
if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 300)) {
|
|
63
|
+
callback(xhr.responseText);
|
|
64
|
+
} else {
|
|
65
|
+
errback(xhr.status, url);
|
|
66
|
+
}
|
|
67
|
+
} else if (async) {
|
|
68
|
+
xhr.onreadystatechange = function () {
|
|
69
|
+
if (xhr.readyState == 4) {
|
|
70
|
+
handleResponse(xhr, callback, errback);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
} else {
|
|
74
|
+
handleResponse(xhr, callback, errback);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
FileManager.prototype.supports = function(filename, currentDirectory, options, environment) {
|
|
78
|
+
return true;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
FileManager.prototype.clearFileCache = function() {
|
|
82
|
+
fileCache = {};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
FileManager.prototype.loadFile = function loadFile(filename, currentDirectory, options, environment, callback) {
|
|
86
|
+
if (currentDirectory && !this.isPathAbsolute(filename)) {
|
|
87
|
+
filename = currentDirectory + filename;
|
|
88
|
+
}
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
options = options || {};
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
// sheet may be set to the stylesheet for the initial load or a collection of properties including
|
|
93
|
+
// some context variables for imports
|
|
94
|
+
var hrefParts = this.extractUrlParts(filename, window.location.href);
|
|
95
|
+
var href = hrefParts.url;
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
if (options.useFileCache && fileCache[href]) {
|
|
98
|
+
try {
|
|
99
|
+
var lessText = fileCache[href];
|
|
100
|
+
callback(null, { contents: lessText, filename: href, webInfo: { lastModified: new Date() }});
|
|
101
|
+
} catch (e) {
|
|
102
|
+
callback({filename: href, message: "Error loading file " + href + " error was " + e.message});
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
103
105
|
}
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
this.doXHR(href, options.mime, function doXHRCallback(data, lastModified) {
|
|
108
|
+
// per file cache
|
|
109
|
+
fileCache[href] = data;
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
};
|
|
111
|
+
// Use remote copy (re-parse)
|
|
112
|
+
callback(null, { contents: data, filename: href, webInfo: { lastModified: lastModified }});
|
|
113
|
+
}, function doXHRError(status, url) {
|
|
114
|
+
callback({ type: 'File', message: "'" + url + "' wasn't found (" + status + ")", href: href });
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
117
|
|
|
118
|
-
return FileManager;
|
|
118
|
+
return FileManager;
|
|
119
119
|
};
|