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.
Files changed (148) hide show
  1. package/.idea/inspectionProfiles/Project_Default.xml +1 -0
  2. package/.idea/jsLinters/jscs.xml +4 -0
  3. package/.idea/jsLinters/jshint.xml +58 -4
  4. package/.idea/workspace.xml +499 -760
  5. package/.jscsrc +73 -0
  6. package/.jshintrc +0 -2
  7. package/.travis.yml +1 -0
  8. package/CHANGELOG.md +59 -0
  9. package/Gruntfile.js +37 -3
  10. package/appveyor.yml +5 -0
  11. package/bin/lessc +383 -316
  12. package/bower.json +1 -1
  13. package/dist/less.js +1638 -1244
  14. package/dist/less.min.js +7 -7
  15. package/lib/less/contexts.js +3 -3
  16. package/lib/less/data/unit-conversions.js +3 -3
  17. package/lib/less/environment/abstract-file-manager.js +8 -8
  18. package/lib/less/environment/environment.js +2 -2
  19. package/lib/less/functions/color-blending.js +3 -3
  20. package/lib/less/functions/color.js +20 -12
  21. package/lib/less/functions/data-uri.js +26 -18
  22. package/lib/less/functions/math.js +1 -1
  23. package/lib/less/functions/number.js +2 -2
  24. package/lib/less/functions/string.js +3 -1
  25. package/lib/less/functions/svg.js +12 -15
  26. package/lib/less/functions/types.js +33 -10
  27. package/lib/less/import-manager.js +14 -9
  28. package/lib/less/index.js +2 -1
  29. package/lib/less/less-error.js +1 -1
  30. package/lib/less/logger.js +2 -2
  31. package/lib/less/parse-tree.js +48 -42
  32. package/lib/less/parse.js +68 -0
  33. package/lib/less/parser/parser-input.js +6 -5
  34. package/lib/less/parser/parser.js +76 -29
  35. package/lib/less/plugin-manager.js +30 -3
  36. package/lib/less/render.js +11 -37
  37. package/lib/less/source-map-builder.js +4 -0
  38. package/lib/less/source-map-output.js +6 -6
  39. package/lib/less/transform-tree.js +4 -4
  40. package/lib/less/tree/anonymous.js +1 -1
  41. package/lib/less/tree/assignment.js +0 -1
  42. package/lib/less/tree/call.js +1 -1
  43. package/lib/less/tree/color.js +6 -6
  44. package/lib/less/tree/condition.js +9 -5
  45. package/lib/less/tree/debug-info.js +6 -2
  46. package/lib/less/tree/dimension.js +5 -5
  47. package/lib/less/tree/directive.js +25 -6
  48. package/lib/less/tree/element.js +1 -1
  49. package/lib/less/tree/expression.js +2 -2
  50. package/lib/less/tree/extend.js +3 -3
  51. package/lib/less/tree/import.js +2 -2
  52. package/lib/less/tree/index.js +1 -0
  53. package/lib/less/tree/javascript.js +2 -2
  54. package/lib/less/tree/media.js +20 -19
  55. package/lib/less/tree/mixin-call.js +5 -6
  56. package/lib/less/tree/mixin-definition.js +33 -11
  57. package/lib/less/tree/quoted.js +3 -3
  58. package/lib/less/tree/rule.js +3 -4
  59. package/lib/less/tree/ruleset.js +290 -177
  60. package/lib/less/tree/selector.js +3 -2
  61. package/lib/less/tree/unit.js +2 -0
  62. package/lib/less/tree/url.js +5 -2
  63. package/lib/less/tree/value.js +2 -2
  64. package/lib/less/tree/variable.js +1 -1
  65. package/lib/less/visitors/extend-visitor.js +72 -36
  66. package/lib/less/visitors/import-sequencer.js +20 -14
  67. package/lib/less/visitors/import-visitor.js +15 -12
  68. package/lib/less/visitors/to-css-visitor.js +41 -9
  69. package/lib/less-browser/add-default-options.js +5 -1
  70. package/lib/less-browser/bootstrap.js +10 -8
  71. package/lib/less-browser/cache.js +3 -3
  72. package/lib/less-browser/file-manager.js +96 -96
  73. package/lib/less-browser/index.js +206 -205
  74. package/lib/less-browser/log-listener.js +2 -2
  75. package/lib/less-browser/utils.js +6 -6
  76. package/lib/less-node/file-manager.js +58 -30
  77. package/lib/less-node/image-size.js +34 -0
  78. package/lib/less-node/index.js +6 -3
  79. package/lib/less-node/lessc-helper.js +3 -2
  80. package/lib/less-node/plugin-loader.js +3 -3
  81. package/lib/less-node/url-file-manager.js +6 -3
  82. package/lib/less-rhino/index.js +15 -13
  83. package/lib/source-map/source-map-0.1.31.js +1 -1
  84. package/package.json +10 -7
  85. package/test/browser/common.js +13 -11
  86. package/test/browser/css/relative-urls/urls.css +1 -0
  87. package/test/browser/css/urls.css +6 -3
  88. package/test/browser/jasmine-jsreporter.js +2 -3
  89. package/test/browser/less/nested-gradient-with-svg-gradient/mixin-consumer.less +5 -0
  90. package/test/browser/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +15 -0
  91. package/test/browser/less/relative-urls/urls.less +1 -0
  92. package/test/browser/less/urls.less +1 -0
  93. package/test/browser/runner-browser-options.js +23 -23
  94. package/test/browser/runner-errors-options.js +0 -1
  95. package/test/browser/runner-errors-spec.js +1 -2
  96. package/test/browser/runner-global-vars-spec.js +1 -1
  97. package/test/browser/runner-legacy-options.js +0 -1
  98. package/test/browser/runner-main-options.js +5 -5
  99. package/test/browser/runner-main-spec.js +1 -1
  100. package/test/browser/runner-no-js-errors-spec.js +0 -1
  101. package/test/browser/runner-production-options.js +0 -1
  102. package/test/browser/runner-relative-urls-options.js +0 -1
  103. package/test/browser/runner-rootpath-options.js +0 -1
  104. package/test/browser/runner-rootpath-relative-options.js +0 -1
  105. package/test/browser/runner-strict-units-options.js +0 -1
  106. package/test/copy-bom.js +72 -0
  107. package/test/css/comments.css +1 -0
  108. package/test/css/css-3.css +2 -0
  109. package/test/css/functions.css +10 -0
  110. package/test/css/import-interpolation.css +7 -0
  111. package/test/css/import-reference.css +25 -0
  112. package/test/css/include-path/include-path.css +6 -0
  113. package/test/css/mixins-important.css +12 -0
  114. package/test/css/selectors.css +15 -1
  115. package/test/css/static-urls/urls.css +1 -0
  116. package/test/css/url-args/urls.css +3 -3
  117. package/test/css/urls.css +13 -4
  118. package/test/css/variables.css +7 -1
  119. package/test/data/image.svg +3 -0
  120. package/test/index.js +15 -10
  121. package/test/less/comments.less +1 -0
  122. package/test/less/css-3.less +3 -0
  123. package/test/less/css-guards.less +2 -1
  124. package/test/less/errors/detached-ruleset-2.txt +1 -1
  125. package/test/less/errors/import-missing.txt +1 -1
  126. package/test/less/errors/parens-error-1.txt +1 -1
  127. package/test/less/errors/parens-error-2.txt +1 -1
  128. package/test/less/errors/parens-error-3.txt +1 -1
  129. package/test/less/errors/single-character.less +1 -0
  130. package/test/less/errors/single-character.txt +2 -0
  131. package/test/less/functions.less +18 -0
  132. package/test/less/import/import-interpolation.less +1 -0
  133. package/test/less/import/import-reference.less +38 -0
  134. package/test/less/import/imports/logo.less +1 -0
  135. package/test/less/import-reference.less +3 -1
  136. package/test/less/import.less +2 -0
  137. package/test/less/include-path/include-path.less +6 -0
  138. package/test/less/mixins-important.less +28 -0
  139. package/test/less/nested-gradient-with-svg-gradient/mixin-consumer.less +5 -0
  140. package/test/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +15 -0
  141. package/test/less/selectors.less +29 -4
  142. package/test/less/sourcemaps-empty/empty.less +0 -0
  143. package/test/less/sourcemaps-empty/var-defs.less +1 -0
  144. package/test/less/urls.less +10 -1
  145. package/test/less/variables.less +17 -3
  146. package/test/less-test.js +133 -52
  147. package/test/modify-vars.js +14 -12
  148. 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 FileManager = function() {
26
- };
7
+ var fileCache = {};
27
8
 
28
- FileManager.prototype = new AbstractFileManager();
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
- FileManager.prototype.alwaysMakePathsAbsolute = function alwaysMakePathsAbsolute() {
31
- return true;
32
- };
33
- FileManager.prototype.join = function join(basePath, laterPath) {
34
- if (!basePath) {
35
- return laterPath;
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 xhr = getXMLHttpRequest();
42
- var async = options.isFileProtocol ? options.fileAsync : options.async;
25
+ var FileManager = function() {
26
+ };
43
27
 
44
- if (typeof(xhr.overrideMimeType) === 'function') {
45
- xhr.overrideMimeType('text/css');
46
- }
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);
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
- 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);
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
- } else if (async) {
68
- xhr.onreadystatechange = function () {
69
- if (xhr.readyState == 4) {
70
- handleResponse(xhr, callback, errback);
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
- FileManager.prototype.loadFile = function loadFile(filename, currentDirectory, options, environment, callback) {
86
- if (currentDirectory && !this.isPathAbsolute(filename)) {
87
- filename = currentDirectory + filename;
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
- options = options || {};
90
+ options = options || {};
91
91
 
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;
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
- 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});
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
- this.doXHR(href, options.mime, function doXHRCallback(data, lastModified) {
108
- // per file cache
109
- fileCache[href] = data;
107
+ this.doXHR(href, options.mime, function doXHRCallback(data, lastModified) {
108
+ // per file cache
109
+ fileCache[href] = data;
110
110
 
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
- };
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
  };