less 3.0.0-pre.2 → 3.0.1

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 (205) hide show
  1. package/.eslintrc.json +88 -0
  2. package/.github/stale.yml +17 -0
  3. package/.project +17 -0
  4. package/.settings/org.eclipse.buildship.core.prefs +2 -0
  5. package/.travis.yml +22 -3
  6. package/.vscode/launch.json +14 -0
  7. package/CHANGELOG.md +27 -0
  8. package/Gruntfile.js +191 -86
  9. package/README.md +5 -7
  10. package/appveyor.yml +9 -10
  11. package/bin/lessc +37 -50
  12. package/dist/less.js +1357 -1269
  13. package/dist/less.min.js +7 -7
  14. package/lib/less/contexts.js +20 -16
  15. package/lib/less/default-options.js +65 -0
  16. package/lib/less/environment/abstract-file-manager.js +13 -14
  17. package/lib/less/environment/abstract-plugin-loader.js +45 -36
  18. package/lib/less/environment/environment.js +5 -0
  19. package/lib/less/functions/boolean.js +15 -0
  20. package/lib/less/functions/color.js +54 -24
  21. package/lib/less/functions/data-uri.js +5 -2
  22. package/lib/less/functions/function-registry.js +1 -1
  23. package/lib/less/functions/index.js +2 -1
  24. package/lib/less/functions/number.js +2 -2
  25. package/lib/less/functions/string.js +2 -2
  26. package/lib/less/functions/svg.js +4 -4
  27. package/lib/less/import-manager.js +41 -29
  28. package/lib/less/index.js +28 -3
  29. package/lib/less/less-error.js +112 -13
  30. package/lib/less/parse.js +18 -15
  31. package/lib/less/parser/parser-input.js +4 -4
  32. package/lib/less/parser/parser.js +208 -114
  33. package/lib/less/plugin-manager.js +8 -33
  34. package/lib/less/render.js +6 -2
  35. package/lib/less/source-map-builder.js +3 -0
  36. package/lib/less/source-map-output.js +13 -8
  37. package/lib/less/transform-tree.js +2 -2
  38. package/lib/less/tree/anonymous.js +4 -1
  39. package/lib/less/tree/atrule.js +7 -6
  40. package/lib/less/tree/call.js +25 -3
  41. package/lib/less/tree/color.js +2 -2
  42. package/lib/less/tree/debug-info.js +1 -1
  43. package/lib/less/tree/declaration.js +6 -5
  44. package/lib/less/tree/dimension.js +4 -1
  45. package/lib/less/tree/extend.js +2 -2
  46. package/lib/less/tree/import.js +17 -9
  47. package/lib/less/tree/index.js +3 -7
  48. package/lib/less/tree/js-eval-node.js +1 -1
  49. package/lib/less/tree/media.js +3 -14
  50. package/lib/less/tree/mixin-definition.js +3 -3
  51. package/lib/less/tree/node.js +9 -6
  52. package/lib/less/tree/operation.js +1 -1
  53. package/lib/less/tree/property.js +70 -0
  54. package/lib/less/tree/quoted.js +11 -10
  55. package/lib/less/tree/ruleset.js +115 -71
  56. package/lib/less/tree/selector.js +38 -23
  57. package/lib/less/tree/unit.js +1 -1
  58. package/lib/less/tree/value.js +6 -1
  59. package/lib/less/tree/{ruleset-call.js → variable-call.js} +5 -5
  60. package/lib/less/tree/variable.js +6 -6
  61. package/lib/less/utils.js +40 -0
  62. package/lib/less/visitors/extend-visitor.js +14 -14
  63. package/lib/less/visitors/import-visitor.js +2 -2
  64. package/lib/less/visitors/join-selector-visitor.js +1 -1
  65. package/lib/less/visitors/to-css-visitor.js +51 -84
  66. package/lib/less/visitors/visitor.js +15 -15
  67. package/lib/less-browser/bootstrap.js +21 -5
  68. package/lib/less-browser/cache.js +2 -2
  69. package/lib/less-browser/error-reporting.js +5 -5
  70. package/lib/less-browser/file-manager.js +27 -35
  71. package/lib/less-browser/index.js +12 -17
  72. package/lib/less-browser/plugin-loader.js +8 -45
  73. package/lib/less-browser/utils.js +1 -1
  74. package/lib/less-node/file-manager.js +99 -69
  75. package/lib/less-node/fs.js +1 -1
  76. package/lib/less-node/image-size.js +2 -2
  77. package/lib/less-node/index.js +7 -57
  78. package/lib/less-node/lessc-helper.js +38 -38
  79. package/lib/less-node/plugin-loader.js +18 -79
  80. package/lib/less-node/url-file-manager.js +1 -1
  81. package/lib/less-rhino/index.js +29 -44
  82. package/package.json +16 -9
  83. package/test/browser/common.js +54 -18
  84. package/test/browser/css/plugin/plugin.css +3 -0
  85. package/test/browser/jasmine-jsreporter.js +4 -4
  86. package/test/browser/less/plugin/plugin.js +7 -0
  87. package/test/browser/less/plugin/plugin.less +4 -0
  88. package/test/browser/less.js +11685 -13
  89. package/test/browser/runner-browser-options.js +6 -1
  90. package/test/browser/runner-filemanagerPlugin-options.js +3 -2
  91. package/test/browser/runner-legacy-options.js +2 -1
  92. package/test/browser/runner-main-options.js +0 -1
  93. package/test/browser/runner-modify-vars-spec.js +2 -2
  94. package/test/browser/test-runner-template.tmpl +38 -14
  95. package/test/copy-bom.js +1 -1
  96. package/test/css/calc.css +5 -0
  97. package/test/css/comments2.css +1 -1
  98. package/test/css/compression/compression.css +1 -1
  99. package/test/css/css-grid.css +11 -0
  100. package/test/css/debug/linenumbers-all.css +0 -1
  101. package/test/css/debug/linenumbers-comments.css +0 -1
  102. package/test/css/debug/linenumbers-mediaquery.css +0 -1
  103. package/test/css/functions.css +16 -3
  104. package/test/css/import-module.css +9 -0
  105. package/test/css/import.css +0 -1
  106. package/test/css/legacy/legacy.css +1 -1
  107. package/test/css/merge.css +5 -4
  108. package/test/css/plugin-module.css +1 -0
  109. package/test/css/plugin.css +20 -0
  110. package/test/css/property-accessors.css +49 -0
  111. package/test/css/{css.css → strict-math/css.css} +0 -0
  112. package/test/css/{mixins-args.css → strict-math/mixins-args.css} +0 -0
  113. package/test/css/{parens.css → strict-math/parens.css} +0 -0
  114. package/test/import-module/one/1.less +3 -0
  115. package/test/import-module/one/two/2.less +3 -0
  116. package/test/import-module/one/two/three/3.less +3 -0
  117. package/test/import-module/package.json +11 -0
  118. package/test/index.js +55 -49
  119. package/test/less/calc.less +7 -0
  120. package/test/less/css-grid.less +15 -0
  121. package/test/less/detached-rulesets.less +2 -2
  122. package/test/less/errors/color-invalid-hex-code.less +1 -0
  123. package/test/less/errors/color-invalid-hex-code.txt +1 -1
  124. package/test/less/errors/color-invalid-hex-code2.less +1 -0
  125. package/test/less/errors/color-invalid-hex-code2.txt +1 -1
  126. package/test/less/errors/import-missing.txt +1 -1
  127. package/test/less/errors/plugin/plugin-error-2.js +5 -0
  128. package/test/less/errors/plugin/plugin-error-3.js +5 -0
  129. package/test/less/errors/plugin/plugin-error.js +1 -0
  130. package/test/less/errors/plugin-1.less +1 -0
  131. package/test/less/errors/plugin-1.txt +2 -0
  132. package/test/less/errors/plugin-2.less +1 -0
  133. package/test/less/errors/plugin-2.txt +5 -0
  134. package/test/less/errors/plugin-3.less +1 -0
  135. package/test/less/errors/plugin-3.txt +5 -0
  136. package/test/less/functions.less +18 -0
  137. package/test/less/import-module.less +3 -0
  138. package/test/less/import.less +0 -2
  139. package/test/less/legacy/legacy.less +1 -1
  140. package/test/less/media.less +2 -2
  141. package/test/less/merge.less +6 -3
  142. package/test/less/plugin/plugin-collection.js +9 -0
  143. package/test/less/plugin/plugin-local.js +2 -2
  144. package/test/less/plugin/plugin-scope1.js +3 -0
  145. package/test/less/plugin/plugin-scope2.js +3 -0
  146. package/test/less/plugin/plugin-simple.js +7 -0
  147. package/test/less/plugin/plugin-tree-nodes.js +33 -31
  148. package/test/less/plugin-module.less +7 -0
  149. package/test/less/plugin.less +33 -3
  150. package/test/less/property-accessors.less +67 -0
  151. package/test/less/root-registry/file.less +1 -0
  152. package/test/less/root-registry/root.less +3 -0
  153. package/test/less/{css.less → strict-math/css.less} +0 -0
  154. package/test/less/{mixins-args.less → strict-math/mixins-args.less} +0 -0
  155. package/test/less/{parens.less → strict-math/parens.less} +0 -0
  156. package/test/less-bom/calc.less +7 -0
  157. package/test/less-bom/css-grid.less +15 -0
  158. package/test/less-bom/detached-rulesets.less +2 -2
  159. package/test/less-bom/errors/color-invalid-hex-code.less +1 -0
  160. package/test/less-bom/errors/color-invalid-hex-code.txt +1 -1
  161. package/test/less-bom/errors/color-invalid-hex-code2.less +1 -0
  162. package/test/less-bom/errors/color-invalid-hex-code2.txt +1 -1
  163. package/test/less-bom/errors/import-missing.txt +1 -1
  164. package/test/less-bom/errors/plugin/plugin-error-2.js +5 -0
  165. package/test/less-bom/errors/plugin/plugin-error-3.js +5 -0
  166. package/test/less-bom/errors/plugin/plugin-error.js +1 -0
  167. package/test/less-bom/errors/plugin-1.less +1 -0
  168. package/test/less-bom/errors/plugin-1.txt +2 -0
  169. package/test/less-bom/errors/plugin-2.less +1 -0
  170. package/test/less-bom/errors/plugin-2.txt +5 -0
  171. package/test/less-bom/errors/plugin-3.less +1 -0
  172. package/test/less-bom/errors/plugin-3.txt +5 -0
  173. package/test/less-bom/functions.less +18 -0
  174. package/test/less-bom/import-module.less +3 -0
  175. package/test/less-bom/import.less +0 -2
  176. package/test/less-bom/legacy/legacy.less +1 -1
  177. package/test/less-bom/media.less +2 -2
  178. package/test/less-bom/merge.less +6 -3
  179. package/test/less-bom/plugin/plugin-collection.js +9 -0
  180. package/test/less-bom/plugin/plugin-local.js +2 -2
  181. package/test/less-bom/plugin/plugin-scope1.js +3 -0
  182. package/test/less-bom/plugin/plugin-scope2.js +3 -0
  183. package/test/less-bom/plugin/plugin-simple.js +7 -0
  184. package/test/less-bom/plugin/plugin-tree-nodes.js +33 -31
  185. package/test/less-bom/plugin-module.less +7 -0
  186. package/test/less-bom/plugin.less +33 -3
  187. package/test/less-bom/property-accessors.less +67 -0
  188. package/test/less-bom/root-registry/file.less +1 -0
  189. package/test/less-bom/root-registry/root.less +3 -0
  190. package/test/less-bom/{css.less → strict-math/css.less} +0 -0
  191. package/test/less-bom/{mixins-args.less → strict-math/mixins-args.less} +0 -0
  192. package/test/less-bom/{parens.less → strict-math/parens.less} +0 -0
  193. package/test/less-test.js +75 -17
  194. package/test/modify-vars.js +1 -1
  195. package/test/plugins/visitor/index.js +1 -1
  196. package/.jscsrc +0 -73
  197. package/.jshintrc +0 -11
  198. package/lib/less/tree/alpha.js +0 -28
  199. package/lib/less/tree/directive.js +0 -12
  200. package/lib/less/tree/rule.js +0 -12
  201. package/test/less/errors/functions-2-alpha.less +0 -2
  202. package/test/less/errors/functions-2-alpha.txt +0 -3
  203. package/test/less-bom/errors/functions-2-alpha.less +0 -2
  204. package/test/less-bom/errors/functions-2-alpha.txt +0 -3
  205. package/test/sourcemaps/maps/import-map.map +0 -1
@@ -1,80 +1,82 @@
1
1
  functions.addMultiple({
2
2
 
3
3
  "test-comment": function() {
4
- return new tree.Combinator(' ');
4
+ return less.combinator(' ');
5
5
  },
6
- "test-directive": function(arg1, arg2) {
7
- return new tree.Directive(arg1.value, new tree.Anonymous(arg2.value));
6
+ "test-atrule": function(arg1, arg2) {
7
+ return less.atrule(arg1.value, arg2.value);
8
8
  },
9
9
  "test-extend": function() {
10
- //TODO
10
+ // TODO
11
11
  },
12
12
  "test-import": function() {
13
- //TODO
13
+ // TODO
14
14
  },
15
15
  "test-media": function() {
16
- //TODO
16
+ // TODO
17
17
  },
18
18
  "test-mixin-call": function() {
19
- //TODO
19
+ // TODO
20
20
  },
21
21
  "test-mixin-definition": function() {
22
- //TODO
22
+ // TODO
23
23
  },
24
24
  "test-ruleset-call": function() {
25
- return new tree.Combinator(' ');
25
+ return less.combinator(' ');
26
26
  },
27
- // Functions must return something. Must 'return true' if they produce no output.
28
- "test-undefined": function() { },
29
-
30
- // These cause root errors
31
- "test-alpha": function() {
32
- return new tree.Alpha(30);
27
+ // Functions must return something, even if it's false/true
28
+ "test-undefined": function() {
29
+ return;
33
30
  },
31
+ "test-collapse": function() {
32
+ return true;
33
+ },
34
+ // These cause root errors
34
35
  "test-assignment": function() {
35
- return new tree.Assignment("bird", "robin");
36
+ return less.assignment("bird", "robin");
36
37
  },
37
38
  "test-attribute": function() {
38
- return new tree.Attribute("foo", "=", "bar");
39
+ return less.attribute("foo", "=", "bar");
39
40
  },
40
41
  "test-call": function() {
41
- return new tree.Call("foo");
42
+ return less.call("foo");
42
43
  },
43
44
  "test-color": function() {
44
- return new tree.Color([50, 50, 50]);
45
+ return less.color([50, 50, 50]);
45
46
  },
46
47
  "test-condition": function() {
47
- return new tree.Condition('<', new tree.Value([0]), new tree.Value([1]));
48
+ return less.condition('<', less.value([0]), less.value([1]));
48
49
  },
49
50
  "test-detached-ruleset" : function() {
50
- var rule = new tree.Rule('prop', new tree.Anonymous('value'));
51
- return new tree.DetachedRuleset(new tree.Ruleset("", [ rule ]));
51
+ var decl = less.declaration('prop', 'value');
52
+ return less.detachedruleset(less.ruleset("", [ decl ]));
52
53
  },
53
54
  "test-dimension": function() {
54
- return new tree.Dimension(1, 'px');
55
+ return less.dimension(1, 'px');
55
56
  },
56
57
  "test-element": function() {
57
- return new tree.Element('+', 'a');
58
+ return less.element('+', 'a');
58
59
  },
59
60
  "test-expression": function() {
60
- return new tree.Expression([1, 2, 3]);
61
+ return less.expression([1, 2, 3]);
61
62
  },
62
63
  "test-keyword": function() {
63
- return new tree.Keyword('foo');
64
+ return less.keyword('foo');
64
65
  },
65
66
  "test-operation": function() {
66
- return new tree.Operation('+', [1, 2]);
67
+ return less.operation('+', [1, 2]);
67
68
  },
68
69
  "test-quoted": function() {
69
- return new tree.Quoted('"', 'foo');
70
+ return less.quoted('"', 'foo');
70
71
  },
71
72
  "test-selector": function() {
72
- return new tree.Selector([new tree.Element('a')]);
73
+ var sel = less.selector('.a.b');
74
+ return sel;
73
75
  },
74
76
  "test-url": function() {
75
- return new tree.URL('http://google.com');
77
+ return less.url('http://google.com');
76
78
  },
77
79
  "test-value": function() {
78
- return new tree.Value([1]);
80
+ return less.value([1]);
79
81
  }
80
82
  });
@@ -0,0 +1,7 @@
1
+ // Test NPM import
2
+ @plugin "clean-css";
3
+
4
+ a {
5
+ background: none;
6
+ }
7
+
@@ -1,5 +1,5 @@
1
1
  // importing plugin globally
2
- @plugin "./plugin/plugin-global";
2
+ @plugin "plugin/plugin-global";
3
3
 
4
4
  // transitively include plugins from importing another sheet
5
5
  @import "./plugin/plugin-transitive";
@@ -86,8 +86,38 @@
86
86
  .root {
87
87
  @ruleset2();
88
88
  }
89
+ .test-empty {
90
+ val1: foo;
91
+ test-collapse();
92
+ val2: foo;
93
+ }
94
+ .test-simple {
95
+ @plugin "./plugin/plugin-simple";
96
+ value: pi-anon();
97
+ value: (pi() * 2);
98
+ }
99
+ .test-conflicts {
100
+ @plugin "./plugin/plugin-scope1";
101
+ value: foo();
102
+ }
103
+ .test-conflicts {
104
+ @plugin "./plugin/plugin-scope2";
105
+ value: foo();
106
+ }
107
+ .test-conflicts {
108
+ @plugin "./plugin/plugin-scope1";
109
+ value: foo();
110
+ }
111
+ .test-collection {
112
+ @plugin "./plugin/plugin-collection";
113
+ @var: 32;
114
+ store(@var);
115
+ store(5);
116
+ store("bird");
117
+ list: list();
118
+ }
89
119
 
90
- test-directive("@charset"; '"utf-8"');
91
- test-directive("@arbitrary"; "value after ()");
120
+ test-atrule("@charset"; '"utf-8"');
121
+ test-atrule("@arbitrary"; "value after ()");
92
122
 
93
123
 
@@ -0,0 +1,67 @@
1
+ 
2
+ .block_1 {
3
+ color: red;
4
+ background-color: $color;
5
+ @width: 50px;
6
+ width: @width;
7
+ height: ($width / 2);
8
+ @color: red;
9
+ border: 1px solid lighten($color, 10%);
10
+ &:hover {
11
+ color: $color;
12
+ background-color: $color;
13
+ .mixin1();
14
+ }
15
+ .one {
16
+ background: $color;
17
+ }
18
+ content: "${color}";
19
+ prop: $color;
20
+
21
+ }
22
+
23
+ .block_2 {
24
+ color: red;
25
+ .two {
26
+ background-color: $color;
27
+ }
28
+ color: blue;
29
+ }
30
+
31
+ .block_3 {
32
+ color: red;
33
+ .three {
34
+ background-color: $color;
35
+ }
36
+ .mixin2();
37
+ color: blue;
38
+ }
39
+ .block_4 {
40
+ color: red;
41
+ .four {
42
+ background-color: $color;
43
+ }
44
+ color: blue;
45
+ .mixin2();
46
+ }
47
+ // property merging
48
+ a {
49
+ background-color+: red;
50
+ background-color+: foo;
51
+
52
+ &b {
53
+ background: $background-color;
54
+ }
55
+ }
56
+
57
+ .value_as_property {
58
+ prop1: color;
59
+ ${prop1}: #FF0000; // not sure why you'd want to do this, but ok
60
+ }
61
+
62
+ .mixin1() {
63
+ color: green;
64
+ }
65
+ .mixin2() {
66
+ color: yellow;
67
+ }
@@ -0,0 +1 @@
1
+ @charset "utf-8";
@@ -0,0 +1,3 @@
1
+ // https://github.com/less/less.js/issues/3112
2
+ @file: ext();
3
+ @import '@{file}';
File without changes
package/test/less-test.js CHANGED
@@ -1,4 +1,4 @@
1
- /*jshint latedef: nofunc */
1
+ /* jshint latedef: nofunc */
2
2
 
3
3
  module.exports = function() {
4
4
  var path = require('path'),
@@ -19,6 +19,14 @@ module.exports = function() {
19
19
  var normalFolder = 'test/less';
20
20
  var bomFolder = 'test/less-bom';
21
21
 
22
+ // Define String.prototype.endsWith if it doesn't exist (in older versions of node)
23
+ // This is required by the testSourceMap function below
24
+ if (typeof String.prototype.endsWith !== 'function') {
25
+ String.prototype.endsWith = function (str) {
26
+ return this.slice(-str.length) === str;
27
+ }
28
+ }
29
+
22
30
  less.logger.addListener({
23
31
  info: function(msg) {
24
32
  if (isVerbose) {
@@ -37,21 +45,21 @@ module.exports = function() {
37
45
  queueRunning = false;
38
46
  function queue(func) {
39
47
  if (queueRunning) {
40
- //console.log("adding to queue");
48
+ // console.log("adding to queue");
41
49
  queueList.push(func);
42
50
  } else {
43
- //console.log("first in queue - starting");
51
+ // console.log("first in queue - starting");
44
52
  queueRunning = true;
45
53
  func();
46
54
  }
47
55
  }
48
56
  function release() {
49
57
  if (queueList.length) {
50
- //console.log("running next in queue");
58
+ // console.log("running next in queue");
51
59
  var func = queueList.shift();
52
60
  setTimeout(func, 0);
53
61
  } else {
54
- //console.log("stopping queue");
62
+ // console.log("stopping queue");
55
63
  queueRunning = false;
56
64
  }
57
65
  }
@@ -74,6 +82,25 @@ module.exports = function() {
74
82
  });
75
83
 
76
84
  function testSourcemap(name, err, compiledLess, doReplacements, sourcemap, baseFolder) {
85
+ // Check the sourceMappingURL at the bottom of the file
86
+ var expectedSourceMapURL = name + ".css.map",
87
+ sourceMappingPrefix = "/*# sourceMappingURL=",
88
+ sourceMappingSuffix = " */",
89
+ expectedCSSAppendage = sourceMappingPrefix + expectedSourceMapURL + sourceMappingSuffix;
90
+ if (!compiledLess.endsWith(expectedCSSAppendage)) {
91
+ // To display a better error message, we need to figure out what the actual sourceMappingURL value was, if it was even present
92
+ var indexOfSourceMappingPrefix = compiledLess.indexOf(sourceMappingPrefix);
93
+ if (indexOfSourceMappingPrefix === -1) {
94
+ fail("ERROR: sourceMappingURL was not found in " + baseFolder + "/" + name + ".css.");
95
+ return;
96
+ }
97
+
98
+ var startOfSourceMappingValue = indexOfSourceMappingPrefix + sourceMappingPrefix.length,
99
+ indexOfNextSpace = compiledLess.indexOf(" ", startOfSourceMappingValue),
100
+ actualSourceMapURL = compiledLess.substring(startOfSourceMappingValue, indexOfNextSpace === -1 ? compiledLess.length : indexOfNextSpace);
101
+ fail("ERROR: sourceMappingURL should be \"" + expectedSourceMapURL + "\" but is \"" + actualSourceMapURL + "\".");
102
+ }
103
+
77
104
  fs.readFile(path.join('test/', name) + '.json', 'utf8', function (e, expectedSourcemap) {
78
105
  process.stdout.write("- " + path.join(baseFolder, name) + ": ");
79
106
  if (sourcemap === expectedSourcemap) {
@@ -109,32 +136,57 @@ module.exports = function() {
109
136
 
110
137
  function testErrors(name, err, compiledLess, doReplacements, sourcemap, baseFolder) {
111
138
  fs.readFile(path.join(baseFolder, name) + '.txt', 'utf8', function (e, expectedErr) {
112
- process.stdout.write("- " + path.join(baseFolder, name) + ": ");
113
- expectedErr = doReplacements(expectedErr, baseFolder);
139
+ process.stdout.write('- ' + path.join(baseFolder, name) + ": ");
140
+ expectedErr = doReplacements(expectedErr, baseFolder, err && err.filename);
114
141
  if (!err) {
115
142
  if (compiledLess) {
116
- fail("No Error", 'red');
143
+ fail('No Error', 'red');
117
144
  } else {
118
- fail("No Error, No Output");
145
+ fail('No Error, No Output');
119
146
  }
120
147
  } else {
121
- var errMessage = less.formatError(err);
148
+ var errMessage = err.toString();
122
149
  if (errMessage === expectedErr) {
123
150
  ok('OK');
124
151
  } else {
125
- difference("FAIL", expectedErr, errMessage);
152
+ difference('FAIL', expectedErr, errMessage);
126
153
  }
127
154
  }
128
155
  });
129
156
  }
130
157
 
131
- function globalReplacements(input, directory) {
132
- var p = path.join(process.cwd(), directory),
158
+ // https://github.com/less/less.js/issues/3112
159
+ function testJSImport() {
160
+ process.stdout.write("- Testing root function registry");
161
+ less.functions.functionRegistry.add('ext', function() {
162
+ return new less.tree.Anonymous('file');
163
+ });
164
+ var expected = "@charset \"utf-8\";\n";
165
+ toCSS({}, require('path').join(process.cwd(), 'test/less/root-registry/root.less'), function(error, output) {
166
+ if (error) {
167
+ return fail("ERROR: " + error);
168
+ }
169
+ if (output.css === expected) {
170
+ return ok('OK');
171
+ }
172
+ difference("FAIL", expected, output.css);
173
+ });
174
+ }
175
+
176
+ function globalReplacements(input, directory, filename) {
177
+ var path = require('path');
178
+ var p = filename ? path.join(path.dirname(filename), '/') : path.join(process.cwd(), directory),
133
179
  pathimport = path.join(process.cwd(), directory + "import/"),
134
180
  pathesc = p.replace(/[.:/\\]/g, function(a) { return '\\' + (a == '\\' ? '\/' : a); }),
135
181
  pathimportesc = pathimport.replace(/[.:/\\]/g, function(a) { return '\\' + (a == '\\' ? '\/' : a); });
136
182
 
137
183
  return input.replace(/\{path\}/g, p)
184
+ .replace(/\{node\}/g, "")
185
+ .replace(/\{\/node\}/g, "")
186
+ .replace(/\{pathhref\}/g, "")
187
+ .replace(/\{404status\}/g, "")
188
+ .replace(/\{nodepath\}/g, path.join(process.cwd(), 'node_modules', '/'))
189
+ .replace(/\{pathrel\}/g, path.join(path.relative(process.cwd(), p), '/'))
138
190
  .replace(/\{pathesc\}/g, pathesc)
139
191
  .replace(/\{pathimport\}/g, pathimport)
140
192
  .replace(/\{pathimportesc\}/g, pathimportesc)
@@ -197,7 +249,7 @@ module.exports = function() {
197
249
  }
198
250
 
199
251
  fs.readdirSync(path.join(baseFolder, foldername)).forEach(function (file) {
200
- if (! /\.less/.test(file)) { return; }
252
+ if (!/\.less/.test(file)) { return; }
201
253
 
202
254
  var name = getBasename(file);
203
255
 
@@ -213,6 +265,11 @@ module.exports = function() {
213
265
  options.sourceMapRootpath = "testweb/";
214
266
  // TODO separate options?
215
267
  options.sourceMap = options;
268
+
269
+ // This options is normally set by the bin/lessc script. Setting it causes the sourceMappingURL comment to be appended to the CSS
270
+ // output. The value is designed to allow the sourceMapBasepath option to be tested, as it should be removed by less before
271
+ // setting the sourceMappingURL value, leaving just the sourceMapOutputFilename and .map extension.
272
+ options.sourceMapFilename = options.sourceMapBasepath + "/" + options.sourceMapOutputFilename + ".map";
216
273
  }
217
274
 
218
275
  options.getVars = function(file) {
@@ -222,7 +279,7 @@ module.exports = function() {
222
279
  var doubleCallCheck = false;
223
280
  queue(function() {
224
281
  toCSS(options, path.join(baseFolder, foldername + file), function (err, result) {
225
-
282
+
226
283
  if (doubleCallCheck) {
227
284
  totalTests++;
228
285
  fail("less is calling back twice");
@@ -244,7 +301,7 @@ module.exports = function() {
244
301
  if (err.stack) {
245
302
  process.stdout.write(err.stack + "\n");
246
303
  } else {
247
- //this sometimes happen - show the whole error object
304
+ // this sometimes happen - show the whole error object
248
305
  console.log(err);
249
306
  }
250
307
  }
@@ -367,7 +424,7 @@ module.exports = function() {
367
424
  try {
368
425
  process.stdout.write("- Integration - creating parser without options: ");
369
426
  less.render("");
370
- } catch(e) {
427
+ } catch (e) {
371
428
  fail(stylize("FAIL\n", "red"));
372
429
  return;
373
430
  }
@@ -383,6 +440,7 @@ module.exports = function() {
383
440
  testEmptySourcemap: testEmptySourcemap,
384
441
  testNoOptions: testNoOptions,
385
442
  prepBomTest: prepBomTest,
443
+ testJSImport: testJSImport,
386
444
  finished: finished
387
445
  };
388
446
  };
@@ -1,5 +1,5 @@
1
1
  var less = require('../lib/less'),
2
- fs = require('fs');
2
+ fs = require('fs');
3
3
 
4
4
  var input = fs.readFileSync("./test/less/modifyVars/extended.less", 'utf8');
5
5
  var expectedCss = fs.readFileSync('./test/css/modifyVars/extended.css', 'utf8');
@@ -8,7 +8,7 @@
8
8
  run: function (root) {
9
9
  return this._visitor.visit(root);
10
10
  },
11
- visitRule: function (ruleNode, visitArgs) {
11
+ visitDeclaration: function (ruleNode, visitArgs) {
12
12
  if (ruleNode.name != '-some-aribitrary-property') {
13
13
  return ruleNode;
14
14
  } else {
package/.jscsrc DELETED
@@ -1,73 +0,0 @@
1
- {
2
- "disallowImplicitTypeConversion": ["numeric", "binary", "string"],
3
- "disallowKeywords": ["with"],
4
- "disallowMixedSpacesAndTabs": true,
5
- "disallowMultipleLineBreaks": true,
6
- "disallowOperatorBeforeLineBreak": ["."],
7
- "disallowSpaceAfterKeywords": [
8
- "void"//,
9
- //"typeof"
10
- ],
11
- "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~"],
12
- "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
13
- "disallowSpacesInCallExpression": true,
14
- "disallowSpacesInNamedFunctionExpression": {
15
- "beforeOpeningRoundBrace": true},
16
- "disallowTrailingComma": true,
17
- "disallowTrailingWhitespace": false,
18
- "maximumLineLength": 160,
19
- "requireCommaBeforeLineBreak": true,
20
- "requireCurlyBraces": [ "if",
21
- "else",
22
- "for",
23
- "while",
24
- "do",
25
- "try",
26
- "catch"],
27
- "requireOperatorBeforeLineBreak": [ "?",
28
- "=",
29
- "+",
30
- "-",
31
- "/",
32
- "*",
33
- "==",
34
- "===",
35
- "!=",
36
- "!==",
37
- ">",
38
- ">=",
39
- "<",
40
- "<="],
41
- "requireSpaceAfterBinaryOperators": true,
42
- "requireSpaceAfterKeywords": [
43
- "else",
44
- "case",
45
- "try",
46
- "typeof",
47
- "return",
48
- "if",
49
- "for",
50
- "while",
51
- "do"
52
- ],
53
- "requireSpaceBeforeBlockStatements": true,
54
- "requireSpaceBeforeBinaryOperators": [
55
- "=",
56
- "+",
57
- "-",
58
- "/",
59
- "*",
60
- "==",
61
- "===",
62
- "!=",
63
- "!=="
64
- ],
65
- "requireSpaceBeforeBlockStatements": true,
66
- "requireSpaceBetweenArguments": true,
67
- "requireSpacesInConditionalExpression": true,
68
- "requireSpacesInForStatement": true,
69
- "requireSpacesInNamedFunctionExpression": {
70
- "beforeOpeningCurlyBrace": true
71
- },
72
- "validateIndentation": 4
73
- }
package/.jshintrc DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "evil": true,
3
- "latedef": true,
4
- "node": true,
5
- "undef": true,
6
- "unused": "vars",
7
- "noarg": true,
8
- "eqnull": true,
9
- "forin": true,
10
- "predef": ["Promise"]
11
- }
@@ -1,28 +0,0 @@
1
- var Node = require("./node");
2
-
3
- var Alpha = function (val) {
4
- this.value = val;
5
- };
6
- Alpha.prototype = new Node();
7
- Alpha.prototype.type = "Alpha";
8
-
9
- Alpha.prototype.accept = function (visitor) {
10
- this.value = visitor.visit(this.value);
11
- };
12
- Alpha.prototype.eval = function (context) {
13
- if (this.value.eval) { return new Alpha(this.value.eval(context)); }
14
- return this;
15
- };
16
- Alpha.prototype.genCSS = function (context, output) {
17
- output.add("alpha(opacity=");
18
-
19
- if (this.value.genCSS) {
20
- this.value.genCSS(context, output);
21
- } else {
22
- output.add(this.value);
23
- }
24
-
25
- output.add(")");
26
- };
27
-
28
- module.exports = Alpha;
@@ -1,12 +0,0 @@
1
- // Backwards compatibility shim for Directive (AtRule)
2
- var AtRule = require("./atrule");
3
-
4
- var Directive = function () {
5
- var args = Array.prototype.slice.call(arguments);
6
- AtRule.apply(this, args);
7
- };
8
-
9
- Directive.prototype = Object.create(AtRule.prototype);
10
- Directive.prototype.constructor = Directive;
11
-
12
- module.exports = Directive;
@@ -1,12 +0,0 @@
1
- // Backwards compatibility shim for Rule (Declaration)
2
- var Declaration = require("./declaration");
3
-
4
- var Rule = function () {
5
- var args = Array.prototype.slice.call(arguments);
6
- Declaration.apply(this, args);
7
- };
8
-
9
- Rule.prototype = Object.create(Declaration.prototype);
10
- Rule.prototype.constructor = Rule;
11
-
12
- module.exports = Rule;
@@ -1,2 +0,0 @@
1
- @plugin "../plugin/plugin-tree-nodes";
2
- test-alpha();
@@ -1,3 +0,0 @@
1
- SyntaxError: Alpha node returned by a function is not valid here in {path}functions-2-alpha.less on line 2, column 1:
2
- 1 @plugin "../plugin/plugin-tree-nodes";
3
- 2 test-alpha();
@@ -1,2 +0,0 @@
1
- @plugin "../plugin/plugin-tree-nodes";
2
- test-alpha();
@@ -1,3 +0,0 @@
1
- SyntaxError: Alpha node returned by a function is not valid here in {path}functions-2-alpha.less on line 2, column 1:
2
- 1 @plugin "../plugin/plugin-tree-nodes";
3
- 2 test-alpha();
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../less/import.less","../../less/import/import-test-b.less","../../less/import/import-test-e.less","../../less/import/import-test-c.less","../../less/import/import-test-f.less","../../less/import/deeper/deeper-2/url-import-2.less","../../less/import/import-test-d.css"],"names":[],"mappings":"AA6BA,SAAS;;;6DA1BqE;YAKlE,sBAAqC;AAEjD;ECLE,YAAA;EACA,UAAA;EDMA,WAAA;EACA,WAAA;;mBAE0D;EEd5D;IAAO,WAAA;;;ACEP;EACE,UAAA;;AFAF;EACE,YAAA;EACA,UAAA;;AGJF;EACE,YAAA;;ACHF;EACE,UAAA;;mBLkB+E;EMnBjF;IAAO,aAAA;;;mBNqBgE;EEpBvE;IAAO,WAAA;;;mBFsB+E;EMvBtF;IAAO,aAAA;;;ANyBP;EExBA;IAAO,WAAA","file":"../import.css"}