less 2.6.0 → 2.7.2

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 (144) hide show
  1. package/.travis.yml +3 -2
  2. package/CHANGELOG.md +30 -2
  3. package/Gruntfile.js +2 -3
  4. package/README.md +2 -2
  5. package/appveyor.yml +1 -0
  6. package/bin/lessc +47 -23
  7. package/dist/less.js +914 -582
  8. package/dist/less.min.js +9 -12
  9. package/lib/less/environment/abstract-file-manager.js +2 -2
  10. package/lib/less/functions/color.js +6 -3
  11. package/lib/less/index.js +1 -1
  12. package/lib/less/parser/parser-input.js +69 -69
  13. package/lib/less/parser/parser.js +111 -51
  14. package/lib/less/tree/anonymous.js +1 -1
  15. package/lib/less/tree/call.js +7 -4
  16. package/lib/less/tree/comment.js +2 -0
  17. package/lib/less/tree/directive.js +1 -0
  18. package/lib/less/tree/extend.js +1 -0
  19. package/lib/less/tree/import.js +1 -0
  20. package/lib/less/tree/media.js +1 -0
  21. package/lib/less/tree/mixin-call.js +1 -0
  22. package/lib/less/tree/mixin-definition.js +2 -1
  23. package/lib/less/tree/rule.js +1 -0
  24. package/lib/less/tree/ruleset-call.js +1 -0
  25. package/lib/less/tree/ruleset.js +86 -85
  26. package/lib/less/tree/unit.js +2 -2
  27. package/lib/less/visitors/extend-visitor.js +5 -5
  28. package/lib/less/visitors/to-css-visitor.js +20 -10
  29. package/lib/less-browser/error-reporting.js +10 -10
  30. package/lib/less-browser/index.js +48 -25
  31. package/lib/less-node/file-manager.js +1 -1
  32. package/lib/less-node/lessc-helper.js +2 -2
  33. package/lib/source-map/source-map-0.1.31.js +1 -1
  34. package/package.json +29 -22
  35. package/test/browser/common.js +29 -8
  36. package/test/browser/less/console-errors/test-error.txt +1 -1
  37. package/test/browser/less.js +13 -16
  38. package/test/browser/runner-production-options.js +1 -1
  39. package/test/css/comments2.css +6 -0
  40. package/test/css/no-strict-math/mixins-guards.css +12 -0
  41. package/test/css/no-strict-math/no-sm-operations.css +3 -0
  42. package/test/css/operations.css +1 -1
  43. package/test/css/plugin.css +5 -0
  44. package/test/less/comments.less +1 -1
  45. package/test/less/comments2.less +11 -0
  46. package/test/less/errors/detached-ruleset-3.txt +1 -1
  47. package/test/less/errors/functions-1.less +2 -0
  48. package/test/less/errors/functions-1.txt +3 -0
  49. package/test/less/errors/functions-10-keyword.less +2 -0
  50. package/test/less/errors/functions-10-keyword.txt +3 -0
  51. package/test/less/errors/functions-11-operation.less +2 -0
  52. package/test/less/errors/functions-11-operation.txt +3 -0
  53. package/test/less/errors/functions-12-quoted.less +2 -0
  54. package/test/less/errors/functions-12-quoted.txt +3 -0
  55. package/test/less/errors/functions-13-selector.less +2 -0
  56. package/test/less/errors/functions-13-selector.txt +3 -0
  57. package/test/less/errors/functions-14-url.less +2 -0
  58. package/test/less/errors/functions-14-url.txt +3 -0
  59. package/test/less/errors/functions-15-value.less +2 -0
  60. package/test/less/errors/functions-15-value.txt +3 -0
  61. package/test/less/errors/functions-2-alpha.less +2 -0
  62. package/test/less/errors/functions-2-alpha.txt +3 -0
  63. package/test/less/errors/functions-3-assignment.less +2 -0
  64. package/test/less/errors/functions-3-assignment.txt +3 -0
  65. package/test/less/errors/functions-4-call.less +2 -0
  66. package/test/less/errors/functions-4-call.txt +3 -0
  67. package/test/less/errors/functions-5-color-2.less +1 -0
  68. package/test/less/errors/functions-5-color-2.txt +2 -0
  69. package/test/less/errors/functions-5-color.less +2 -0
  70. package/test/less/errors/functions-5-color.txt +3 -0
  71. package/test/less/errors/functions-6-condition.less +2 -0
  72. package/test/less/errors/functions-6-condition.txt +3 -0
  73. package/test/less/errors/functions-7-dimension.less +2 -0
  74. package/test/less/errors/functions-7-dimension.txt +3 -0
  75. package/test/less/errors/functions-8-element.less +2 -0
  76. package/test/less/errors/functions-8-element.txt +3 -0
  77. package/test/less/errors/functions-9-expression.less +2 -0
  78. package/test/less/errors/functions-9-expression.txt +3 -0
  79. package/test/less/errors/property-in-root.txt +1 -1
  80. package/test/less/errors/property-in-root2.txt +1 -1
  81. package/test/less/errors/property-in-root3.txt +1 -1
  82. package/test/less/errors/root-func-undefined-1.less +1 -0
  83. package/test/less/errors/root-func-undefined-1.txt +2 -0
  84. package/test/less/errors/root-func-undefined-2.less +2 -0
  85. package/test/less/errors/root-func-undefined-2.txt +3 -0
  86. package/test/less/extend-chaining.less +1 -1
  87. package/test/less/merge.less +4 -4
  88. package/test/less/mixins-guards.less +1 -1
  89. package/test/less/no-strict-math/mixins-guards.less +25 -0
  90. package/test/less/no-strict-math/no-sm-operations.less +4 -1
  91. package/test/less/operations.less +1 -1
  92. package/test/less/plugin/plugin-tree-nodes.js +80 -0
  93. package/test/less/plugin.less +8 -0
  94. package/test/less-bom/comments.less +1 -1
  95. package/test/less-bom/comments2.less +11 -0
  96. package/test/less-bom/errors/detached-ruleset-3.txt +1 -1
  97. package/test/less-bom/errors/functions-1.less +2 -0
  98. package/test/less-bom/errors/functions-1.txt +3 -0
  99. package/test/less-bom/errors/functions-10-keyword.less +2 -0
  100. package/test/less-bom/errors/functions-10-keyword.txt +3 -0
  101. package/test/less-bom/errors/functions-11-operation.less +2 -0
  102. package/test/less-bom/errors/functions-11-operation.txt +3 -0
  103. package/test/less-bom/errors/functions-12-quoted.less +2 -0
  104. package/test/less-bom/errors/functions-12-quoted.txt +3 -0
  105. package/test/less-bom/errors/functions-13-selector.less +2 -0
  106. package/test/less-bom/errors/functions-13-selector.txt +3 -0
  107. package/test/less-bom/errors/functions-14-url.less +2 -0
  108. package/test/less-bom/errors/functions-14-url.txt +3 -0
  109. package/test/less-bom/errors/functions-15-value.less +2 -0
  110. package/test/less-bom/errors/functions-15-value.txt +3 -0
  111. package/test/less-bom/errors/functions-2-alpha.less +2 -0
  112. package/test/less-bom/errors/functions-2-alpha.txt +3 -0
  113. package/test/less-bom/errors/functions-3-assignment.less +2 -0
  114. package/test/less-bom/errors/functions-3-assignment.txt +3 -0
  115. package/test/less-bom/errors/functions-4-call.less +2 -0
  116. package/test/less-bom/errors/functions-4-call.txt +3 -0
  117. package/test/less-bom/errors/functions-5-color-2.less +1 -0
  118. package/test/less-bom/errors/functions-5-color-2.txt +2 -0
  119. package/test/less-bom/errors/functions-5-color.less +2 -0
  120. package/test/less-bom/errors/functions-5-color.txt +3 -0
  121. package/test/less-bom/errors/functions-6-condition.less +2 -0
  122. package/test/less-bom/errors/functions-6-condition.txt +3 -0
  123. package/test/less-bom/errors/functions-7-dimension.less +2 -0
  124. package/test/less-bom/errors/functions-7-dimension.txt +3 -0
  125. package/test/less-bom/errors/functions-8-element.less +2 -0
  126. package/test/less-bom/errors/functions-8-element.txt +3 -0
  127. package/test/less-bom/errors/functions-9-expression.less +2 -0
  128. package/test/less-bom/errors/functions-9-expression.txt +3 -0
  129. package/test/less-bom/errors/property-in-root.txt +1 -1
  130. package/test/less-bom/errors/property-in-root2.txt +1 -1
  131. package/test/less-bom/errors/property-in-root3.txt +1 -1
  132. package/test/less-bom/errors/root-func-undefined-1.less +1 -0
  133. package/test/less-bom/errors/root-func-undefined-1.txt +2 -0
  134. package/test/less-bom/errors/root-func-undefined-2.less +2 -0
  135. package/test/less-bom/errors/root-func-undefined-2.txt +3 -0
  136. package/test/less-bom/extend-chaining.less +1 -1
  137. package/test/less-bom/merge.less +4 -4
  138. package/test/less-bom/mixins-guards.less +1 -1
  139. package/test/less-bom/no-strict-math/mixins-guards.less +25 -0
  140. package/test/less-bom/no-strict-math/no-sm-operations.less +4 -1
  141. package/test/less-bom/operations.less +1 -1
  142. package/test/less-bom/plugin/plugin-tree-nodes.js +80 -0
  143. package/test/less-bom/plugin.less +8 -0
  144. package/test/sourcemaps/maps/import-map.map +1 -0
package/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: node_js
2
2
  node_js:
3
- - "4.2.0"
4
- - "4.0.0"
3
+ - "6"
4
+ - "4"
5
5
  - "0.12"
6
6
  - "0.10"
7
7
  install:
@@ -9,6 +9,7 @@ install:
9
9
  - npm install
10
10
  env:
11
11
  global:
12
+ - PHANTOMJS_CDNURL=http://cnpmjs.org/downloads
12
13
  - secure: TrNVruWYaUK5ALga1y7wRY+MLjWJECUSCsBmKW5EUmIevOUxqHWu7M89FANKxstEeFRRAGH3QJbloRxnzIgh0U0ah5npE9XA1bYXGO5khoXeIyk7pNRfjIo8aEnJH1Vp8vWA6J6ovxdJ7lCFKEGvGKxGde50knVl7KFVVULlX2U=
13
14
  - secure: Rzh+CEI7YRvvVkOruPE8Z0dkU0s13V6b6cpqbN72vxbJl/Jm5PUZkjTFJdkWJrW3ErhCKX6EC7XdGvrclqEA9WAqKzrecqCJYqTnw4MwqiAj6F9wqE/BqhoWg4xPxm0MK/7eJMvLCgjNpe+gc1CaeFJZkLSNWn6nOFke+vVlf9Q=
14
15
  sudo: false
package/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ # 2.7.1 HOTFIX
2
+
3
+ 2016-05-09
4
+
5
+ - Revert commit 470af20 (source map performance) which broke source maps
6
+
7
+ # 2.7.0
8
+
9
+ 2016-05-07
10
+
11
+ - Fixes for contrast() function
12
+ - Allow root functions for plugins
13
+ - Allow semi-colon separators in functions
14
+ - Performance improvements for source maps
15
+ - Fix "blank page" issue in browser
16
+ - Compatibility fixes for Node 6.x
17
+ - Fix AST to include single-line comments
18
+ - Fix reversion for "color-like" words (outputting color values)
19
+
20
+ # 2.6.1
21
+
22
+ 2016-03-04
23
+
24
+ - Update Less.js dependencies
25
+ - Fix comments after named color regression
26
+ - use instanceof operator instead of class comparison optimization
27
+ - disallow whitespace in variable calls
28
+
1
29
  # 2.6.0
2
30
 
3
31
  2016-01-29
@@ -10,7 +38,7 @@
10
38
  - Fixed extend leaking through nested parent selector. #2586
11
39
  - Added "or" keyword and allowed arbitrary logical expression in guards
12
40
  - Fixing #2124 - Parsing Error "Unrecognised input" for color operations
13
- - Logical operator and now has higher precence then logical operator or.
41
+ - Logical operator ```and``` now has higher precedence than logical operator ```or```.
14
42
  - Allow unknown at-rules w/o {} block
15
43
 
16
44
  # 2.5.3
@@ -132,7 +160,7 @@
132
160
  - Improved keyword and anonymous usage with the replace function
133
161
  - Added `getCSSAppendage` to sourcemap builder to avoid duplication in plugins
134
162
  - Fix problem with plugins when used with the promises version of render
135
- - If the render callback throws an exception it now propogates instead of calling the callback again with an error
163
+ - If the render callback throws an exception it now propagates instead of calling the callback again with an error
136
164
 
137
165
  # 2.1.0
138
166
 
package/Gruntfile.js CHANGED
@@ -14,18 +14,17 @@ module.exports = function (grunt) {
14
14
  build: grunt.file.readYAML('build/build.yml'),
15
15
  pkg: grunt.file.readJSON('package.json'),
16
16
  meta: {
17
- license: '<%= _.pluck(pkg.licenses, "type").join(", ") %>',
18
17
  copyright: 'Copyright (c) 2009-<%= grunt.template.today("yyyy") %>',
19
18
  banner: '/*!\n' +
20
19
  ' * Less - <%= pkg.description %> v<%= pkg.version %>\n' +
21
20
  ' * http://lesscss.org\n' +
22
21
  ' *\n' +
23
22
  ' * <%= meta.copyright %>, <%= pkg.author.name %> <<%= pkg.author.email %>>\n' +
24
- ' * Licensed under the <%= meta.license %> License.\n' +
23
+ ' * Licensed under the <%= pkg.license %> License.\n' +
25
24
  ' *\n' +
26
25
  ' */\n\n' +
27
26
  ' /**' +
28
- ' * @license <%= meta.license %>\n' +
27
+ ' * @license <%= pkg.license %>\n' +
29
28
  ' */\n\n'
30
29
  },
31
30
 
package/README.md CHANGED
@@ -4,12 +4,12 @@
4
4
 
5
5
  # [Less.js](http://lesscss.org)
6
6
 
7
- [![Join the chat at https://gitter.im/less/less.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/less/less.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8
-
9
7
  > The **dynamic** stylesheet language. [http://lesscss.org](http://lesscss.org).
10
8
 
11
9
  This is the JavaScript, official, stable version of Less.
12
10
 
11
+ ###### :point_right: [![Join the chat at https://gitter.im/less/less.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/less/less.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) <sup>Chat with Less.js users</sup>
12
+
13
13
 
14
14
  ## Getting Started
15
15
 
package/appveyor.yml CHANGED
@@ -4,6 +4,7 @@ environment:
4
4
  - nodejs_version: "0.10"
5
5
  - nodejs_version: "0.12"
6
6
  - nodejs_version: "4"
7
+ - nodejs_version: "6"
7
8
 
8
9
  # Install scripts. (runs after repo cloning)
9
10
  install:
package/bin/lessc CHANGED
@@ -40,18 +40,32 @@ var silent = false,
40
40
  plugins: plugins
41
41
  };
42
42
  var sourceMapOptions = {};
43
- var continueProcessing = true,
44
- currentErrorcode;
45
-
46
- // calling process.exit does not flush stdout always
47
- // so use this to set the exit code
48
- process.on('exit', function() { process.reallyExit(currentErrorcode); });
43
+ var continueProcessing = true;
44
+
45
+ // Calling process.exit does not flush stdout always. Instead of exiting the process, we set the process' exitCode,
46
+ // close all handles and wait for the event loop to exit the process.
47
+ // @see https://github.com/nodejs/node/issues/6409
48
+ // Unfortunately, node 0.10.x does not support setting process.exitCode, so we need to call reallyExit() explicitly.
49
+ // @see https://nodejs.org/api/process.html#process_process_exitcode
50
+ // Additionally we also need to make sure that uncaughtExceptions are never swallowed.
51
+ // @see https://github.com/less/less.js/issues/2881
52
+ // This code can safely be removed if node 0.10.x is not supported anymore.
53
+ process.on("exit", function() { process.reallyExit(process.exitCode); });
54
+ process.on("uncaughtException", function(err) {
55
+ console.error(err);
56
+ process.exitCode = 1;
57
+ });
58
+ // This code will still be required because otherwise rejected promises would not be reported to the user
59
+ process.on("unhandledRejection", function(err) {
60
+ console.error(err);
61
+ process.exitCode = 1;
62
+ });
49
63
 
50
64
  var checkArgFunc = function(arg, option) {
51
65
  if (!option) {
52
66
  console.error(arg + " option requires a parameter");
53
67
  continueProcessing = false;
54
- currentErrorcode = 1;
68
+ process.exitCode = 1;
55
69
  return false;
56
70
  }
57
71
  return true;
@@ -62,7 +76,7 @@ var checkBooleanArg = function(arg) {
62
76
  if (!onOff) {
63
77
  console.error(" unable to parse " + arg + " as a boolean. use one of on/t/true/y/yes/off/f/false/n/no");
64
78
  continueProcessing = false;
65
- currentErrorcode = 1;
79
+ process.exitCode = 1;
66
80
  return false;
67
81
  }
68
82
  return Boolean(onOff[2]);
@@ -252,7 +266,7 @@ function printUsage() {
252
266
  } else {
253
267
  console.error("Unable to load plugin " + name +
254
268
  " please make sure that it is installed under or at the same level as less");
255
- currentErrorcode = 1;
269
+ process.exitCode = 1;
256
270
  }
257
271
  break;
258
272
  default:
@@ -263,7 +277,7 @@ function printUsage() {
263
277
  console.error("Unable to interpret argument " + arg +
264
278
  " - if it is a plugin (less-plugin-" + arg + "), make sure that it is installed under or at" +
265
279
  " the same level as less");
266
- currentErrorcode = 1;
280
+ process.exitCode = 1;
267
281
  }
268
282
  break;
269
283
  }
@@ -288,15 +302,20 @@ function printUsage() {
288
302
  sourceMapOptions.sourceMapInputFilename = input;
289
303
  if (!sourceMapOptions.sourceMapFullFilename) {
290
304
  if (!output && !sourceMapFileInline) {
291
- console.log("the sourcemap option only has an optional filename if the css filename is given");
292
- console.log("consider adding --source-map-map-inline which embeds the sourcemap into the css");
305
+ console.error("the sourcemap option only has an optional filename if the css filename is given");
306
+ console.error("consider adding --source-map-map-inline which embeds the sourcemap into the css");
307
+ process.exitCode = 1;
293
308
  return;
294
309
  }
295
310
  // its in the same directory, so always just the basename
296
- sourceMapOptions.sourceMapOutputFilename = path.basename(output);
297
- sourceMapOptions.sourceMapFullFilename = output + ".map";
311
+ if (output) {
312
+ sourceMapOptions.sourceMapOutputFilename = path.basename(output);
313
+ sourceMapOptions.sourceMapFullFilename = output + ".map";
314
+ }
298
315
  // its in the same directory, so always just the basename
299
- sourceMapOptions.sourceMapFilename = path.basename(sourceMapOptions.sourceMapFullFilename);
316
+ if ('sourceMapFullFilename' in sourceMapOptions) {
317
+ sourceMapOptions.sourceMapFilename = path.basename(sourceMapOptions.sourceMapFullFilename);
318
+ }
300
319
  } else if (options.sourceMap && !sourceMapFileInline) {
301
320
  var mapFilename = path.resolve(process.cwd(), sourceMapOptions.sourceMapFullFilename),
302
321
  mapDir = path.dirname(mapFilename),
@@ -316,8 +335,8 @@ function printUsage() {
316
335
  }
317
336
 
318
337
  if (sourceMapOptions.sourceMapRootpath === undefined) {
319
- var pathToMap = path.dirname(sourceMapFileInline ? output : sourceMapOptions.sourceMapFullFilename),
320
- pathToInput = path.dirname(sourceMapOptions.sourceMapInputFilename);
338
+ var pathToMap = path.dirname((sourceMapFileInline ? output : sourceMapOptions.sourceMapFullFilename) || '.'),
339
+ pathToInput = path.dirname(sourceMapOptions.sourceMapInputFilename || '.');
321
340
  sourceMapOptions.sourceMapRootpath = path.relative(pathToMap, pathToInput);
322
341
  }
323
342
 
@@ -325,7 +344,7 @@ function printUsage() {
325
344
  console.error("lessc: no input files");
326
345
  console.error("");
327
346
  printUsage();
328
- currentErrorcode = 1;
347
+ process.exitCode = 1;
329
348
  return;
330
349
  }
331
350
 
@@ -345,7 +364,8 @@ function printUsage() {
345
364
 
346
365
  if (options.depends) {
347
366
  if (!outputbase) {
348
- console.log("option --depends requires an output path to be specified");
367
+ console.error("option --depends requires an output path to be specified");
368
+ process.exitCode = 1;
349
369
  return;
350
370
  }
351
371
  process.stdout.write(outputbase + ": ");
@@ -366,6 +386,7 @@ function printUsage() {
366
386
  }
367
387
  console.error('lessc: failed to create file ' + filename);
368
388
  console.error(description);
389
+ process.exitCode = 1;
369
390
  } else {
370
391
  less.logger.info('lessc: wrote ' + filename);
371
392
  }
@@ -383,7 +404,9 @@ function printUsage() {
383
404
  };
384
405
 
385
406
  var writeOutput = function(output, result, onSuccess) {
386
- if (output) {
407
+ if (options.depends) {
408
+ onSuccess();
409
+ } else if (output) {
387
410
  ensureDirectory(output);
388
411
  fs.writeFile(output, result.css, {encoding: 'utf8'}, function (err) {
389
412
  if (err) {
@@ -395,6 +418,7 @@ function printUsage() {
395
418
  }
396
419
  console.error('lessc: failed to create file ' + output);
397
420
  console.error(description);
421
+ process.exitCode = 1;
398
422
  } else {
399
423
  less.logger.info('lessc: wrote ' + output);
400
424
  onSuccess();
@@ -419,7 +443,7 @@ function printUsage() {
419
443
  var parseLessFile = function (e, data) {
420
444
  if (e) {
421
445
  console.error("lessc: " + e.message);
422
- currentErrorcode = 1;
446
+ process.exitCode = 1;
423
447
  return;
424
448
  }
425
449
 
@@ -466,7 +490,7 @@ function printUsage() {
466
490
  },
467
491
  function(err) {
468
492
  less.writeError(err, options);
469
- currentErrorcode = 1;
493
+ process.exitCode = 1;
470
494
  });
471
495
  };
472
496
 
@@ -485,4 +509,4 @@ function printUsage() {
485
509
  parseLessFile(false, buffer);
486
510
  });
487
511
  }
488
- })();
512
+ })();