less 3.8.0 → 3.8.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 (33) hide show
  1. package/Gruntfile.js +1 -3
  2. package/dist/less.js +2352 -98
  3. package/dist/less.min.js +7 -7
  4. package/lib/less/functions/color.js +84 -41
  5. package/lib/less/index.js +1 -1
  6. package/lib/less/parser/parser.js +2 -9
  7. package/lib/less/source-map-output.js +2 -2
  8. package/lib/less/tree/color.js +58 -18
  9. package/lib/less/utils.js +12 -19
  10. package/lib/less-browser/index.js +7 -1
  11. package/package.json +5 -2
  12. package/test/browser/less.js +2352 -98
  13. package/test/css/colors.css +20 -3
  14. package/test/css/css-escapes.css +3 -0
  15. package/test/css/functions.css +4 -4
  16. package/test/less/colors.less +18 -0
  17. package/test/less/css-escapes.less +4 -0
  18. package/test/less/errors/color-func-invalid-color.txt +1 -1
  19. package/test/less/sourcemaps/custom-props.less +8 -0
  20. package/test/less-bom/colors.less +18 -0
  21. package/test/less-bom/css-escapes.less +4 -0
  22. package/test/less-bom/errors/color-func-invalid-color.txt +1 -1
  23. package/test/less-bom/sourcemaps/custom-props.less +8 -0
  24. package/test/less-test.js +26 -12
  25. package/test/sourcemaps/custom-props.json +1 -0
  26. package/test/less/errors/color-invalid-hex-code.less +0 -4
  27. package/test/less/errors/color-invalid-hex-code.txt +0 -4
  28. package/test/less/errors/color-invalid-hex-code2.less +0 -4
  29. package/test/less/errors/color-invalid-hex-code2.txt +0 -4
  30. package/test/less-bom/errors/color-invalid-hex-code.less +0 -4
  31. package/test/less-bom/errors/color-invalid-hex-code.txt +0 -4
  32. package/test/less-bom/errors/color-invalid-hex-code2.less +0 -4
  33. package/test/less-bom/errors/color-invalid-hex-code2.txt +0 -4
@@ -23,7 +23,7 @@
23
23
  color: #1a0000ff;
24
24
  }
25
25
  #alpha #hsla {
26
- color: rgba(61, 45, 41, 0.6);
26
+ color: hsla(11, 20%, 20%, 0.6);
27
27
  }
28
28
  #overflow .a {
29
29
  color: #000000;
@@ -47,10 +47,10 @@
47
47
  color: #333333;
48
48
  }
49
49
  #808080 {
50
- color: #808080;
50
+ color: hsl(0, 0%, 50%);
51
51
  }
52
52
  #00ff00 {
53
- color: #00ff00;
53
+ color: hsl(120, 100%, 50%);
54
54
  }
55
55
  .lightenblue {
56
56
  color: #3333ff;
@@ -85,3 +85,20 @@
85
85
  color: 255;
86
86
  border-color: rgba(255, 0, 0, 0.5);
87
87
  }
88
+ #rrggbbaa {
89
+ test-1: #55FF5599;
90
+ test-2: #5F59;
91
+ test-3: rgba(136, 255, 136, 0.6);
92
+ test-4: rgba(85, 255, 85, 0.1);
93
+ test-5: rgba(85, 255, 85, 0.6);
94
+ test-6: rgba(85, 255, 85, 0.6);
95
+ test-7: rgba(85, 255, 85, 0.5);
96
+ test-8: rgba(var(--color-accent), 0.2);
97
+ test-9: rgb(var(--color-accent));
98
+ test-9: hsla(var(--color-accent));
99
+ test-10: #55FF5599;
100
+ test-11: hsla(120, 100%, 66.66666667%, 0.6);
101
+ test-12: hsla(120, 100%, 66.66666667%, 0.5);
102
+ --semi-transparent-dark-background: #001e00ee;
103
+ --semi-transparent-dark-background-2: #001e00;
104
+ }
@@ -25,3 +25,6 @@ ng\:form {
25
25
  .bootstrap {
26
26
  background-color: #000 \9;
27
27
  }
28
+ textarea {
29
+ font-family: 'helvetica neue', 'wenquanyi micro hei', \5FAE\8F6F\96C5\9ED1, \5B8B\4F53, sans-serif;
30
+ }
@@ -17,9 +17,9 @@
17
17
  desaturate: #29332f;
18
18
  desaturate-relative: #233930;
19
19
  greyscale: #2e2e2e;
20
- hsl-clamp: #ffffff;
21
- spin-p: #bf6a40;
22
- spin-n: #bf4055;
20
+ hsl-clamp: hsl(0, 0%, 100%);
21
+ spin-p: hsl(20, 50%, 50%);
22
+ spin-n: hsl(350, 50%, 50%);
23
23
  luma-white: 100%;
24
24
  luma-black: 0%;
25
25
  luma-black-alpha: 0%;
@@ -168,7 +168,7 @@
168
168
  case-insensitive-2: true;
169
169
  }
170
170
  #alpha {
171
- alpha: rgba(153, 94, 51, 0.6);
171
+ alpha: hsla(25, 50%, 40%, 0.6);
172
172
  alpha2: 0.5;
173
173
  alpha3: 0;
174
174
  }
@@ -96,3 +96,21 @@
96
96
  color: red(rgb(100%, 0, 0));
97
97
  border-color: rgba(100%, 0, 0, 50%);
98
98
  }
99
+
100
+ #rrggbbaa {
101
+ test-1: #55FF5599;
102
+ test-2: #5F59;
103
+ test-3: lighten(#55FF5599, 10%);
104
+ test-4: fade(#5F59, 10%);
105
+ test-5: rgba(#55FF5599);
106
+ test-6: rgba(#5F59);
107
+ test-7: rgba(#5F59, 0.5);
108
+ test-8: rgba(var(--color-accent), 0.2);
109
+ test-9: rgb(var(--color-accent));
110
+ test-9: hsla(var(--color-accent));
111
+ test-10: color('#55FF5599');
112
+ test-11: hsla(#5F59);
113
+ test-12: hsla(#5F59, 0.5);
114
+ --semi-transparent-dark-background: #001e00ee;
115
+ --semi-transparent-dark-background-2: rgba(0, 30, 0, 238); // invalid opacity will be capped
116
+ }
@@ -35,4 +35,8 @@ ng\:form {
35
35
  // In Bootstrap v3
36
36
  .bootstrap {
37
37
  background-color: #000 \9;
38
+ }
39
+
40
+ textarea {
41
+ font-family: 'helvetica neue','wenquanyi micro hei',\5FAE\8F6F\96C5\9ED1, \5B8B\4F53, sans-serif;
38
42
  }
@@ -1,4 +1,4 @@
1
- ArgumentError: error evaluating function `color`: argument must be a color keyword or 3/6 digit hex e.g. #FFF in {path}color-func-invalid-color.less on line 2, column 10:
1
+ ArgumentError: error evaluating function `color`: argument must be a color keyword or 3|4|6|8 digit hex e.g. #FFF in {path}color-func-invalid-color.less on line 2, column 10:
2
2
  1 .test {
3
3
  2 color: color("NOT A COLOR");
4
4
  3 }
@@ -0,0 +1,8 @@
1
+ @color: var(--foo);
2
+
3
+ body {
4
+ border-left: 1px solid @color;
5
+ width: calc(50% - 5px);
6
+ border-top: 1px solid @color;
7
+ }
8
+
@@ -96,3 +96,21 @@
96
96
  color: red(rgb(100%, 0, 0));
97
97
  border-color: rgba(100%, 0, 0, 50%);
98
98
  }
99
+
100
+ #rrggbbaa {
101
+ test-1: #55FF5599;
102
+ test-2: #5F59;
103
+ test-3: lighten(#55FF5599, 10%);
104
+ test-4: fade(#5F59, 10%);
105
+ test-5: rgba(#55FF5599);
106
+ test-6: rgba(#5F59);
107
+ test-7: rgba(#5F59, 0.5);
108
+ test-8: rgba(var(--color-accent), 0.2);
109
+ test-9: rgb(var(--color-accent));
110
+ test-9: hsla(var(--color-accent));
111
+ test-10: color('#55FF5599');
112
+ test-11: hsla(#5F59);
113
+ test-12: hsla(#5F59, 0.5);
114
+ --semi-transparent-dark-background: #001e00ee;
115
+ --semi-transparent-dark-background-2: rgba(0, 30, 0, 238); // invalid opacity will be capped
116
+ }
@@ -35,4 +35,8 @@ ng\:form {
35
35
  // In Bootstrap v3
36
36
  .bootstrap {
37
37
  background-color: #000 \9;
38
+ }
39
+
40
+ textarea {
41
+ font-family: 'helvetica neue','wenquanyi micro hei',\5FAE\8F6F\96C5\9ED1, \5B8B\4F53, sans-serif;
38
42
  }
@@ -1,4 +1,4 @@
1
- ArgumentError: error evaluating function `color`: argument must be a color keyword or 3/6 digit hex e.g. #FFF in {path}color-func-invalid-color.less on line 2, column 10:
1
+ ArgumentError: error evaluating function `color`: argument must be a color keyword or 3|4|6|8 digit hex e.g. #FFF in {path}color-func-invalid-color.less on line 2, column 10:
2
2
  1 .test {
3
3
  2 color: color("NOT A COLOR");
4
4
  3 }
@@ -0,0 +1,8 @@
1
+ @color: var(--foo);
2
+
3
+ body {
4
+ border-left: 1px solid @color;
5
+ width: calc(50% - 5px);
6
+ border-top: 1px solid @color;
7
+ }
8
+
package/test/less-test.js CHANGED
@@ -4,7 +4,8 @@ module.exports = function() {
4
4
  var path = require('path'),
5
5
  fs = require('fs'),
6
6
  copyBom = require('./copy-bom')(),
7
- doBomTest = false;
7
+ doBomTest = false,
8
+ clone = require('clone');
8
9
 
9
10
  var less = require('../lib/less-node');
10
11
  var stylize = require('../lib/less-node/lessc-helper').stylize;
@@ -82,6 +83,10 @@ module.exports = function() {
82
83
  });
83
84
 
84
85
  function testSourcemap(name, err, compiledLess, doReplacements, sourcemap, baseFolder) {
86
+ if (err) {
87
+ fail('ERROR: ' + (err && err.message));
88
+ return;
89
+ }
85
90
  // Check the sourceMappingURL at the bottom of the file
86
91
  var expectedSourceMapURL = name + '.css.map',
87
92
  sourceMappingPrefix = '/*# sourceMappingURL=',
@@ -226,10 +231,10 @@ module.exports = function() {
226
231
  }
227
232
 
228
233
  function runTestSet(options, foldername, verifyFunction, nameModifier, doReplacements, getFilename) {
229
- var options2 = options ? JSON.parse(JSON.stringify(options)) : {};
234
+ options = options ? clone(options) : {};
230
235
  runTestSetInternal(normalFolder, options, foldername, verifyFunction, nameModifier, doReplacements, getFilename);
231
236
  if (doBomTest) {
232
- runTestSetInternal(bomFolder, options2, foldername, verifyFunction, nameModifier, doReplacements, getFilename);
237
+ runTestSetInternal(bomFolder, options, foldername, verifyFunction, nameModifier, doReplacements, getFilename);
233
238
  }
234
239
  }
235
240
 
@@ -237,8 +242,10 @@ module.exports = function() {
237
242
  runTestSetInternal(normalFolder, options, foldername, verifyFunction, nameModifier, doReplacements, getFilename);
238
243
  }
239
244
 
240
- function runTestSetInternal(baseFolder, options, foldername, verifyFunction, nameModifier, doReplacements, getFilename) {
245
+ function runTestSetInternal(baseFolder, opts, foldername, verifyFunction, nameModifier, doReplacements, getFilename) {
241
246
  foldername = foldername || '';
247
+
248
+ var originalOptions = opts || {};
242
249
 
243
250
  if (!doReplacements) {
244
251
  doReplacements = globalReplacements;
@@ -251,6 +258,8 @@ module.exports = function() {
251
258
  fs.readdirSync(path.join(baseFolder, foldername)).forEach(function (file) {
252
259
  if (!/\.less$/.test(file)) { return; }
253
260
 
261
+ var options = clone(originalOptions);
262
+
254
263
  var name = getBasename(file);
255
264
 
256
265
  if (oneTestOnly && name !== oneTestOnly) {
@@ -260,20 +269,24 @@ module.exports = function() {
260
269
  totalTests++;
261
270
 
262
271
  if (options.sourceMap && !options.sourceMap.sourceMapFileInline) {
263
- options.sourceMapOutputFilename = name + '.css';
264
- options.sourceMapBasepath = path.join(process.cwd(), baseFolder);
265
- options.sourceMapRootpath = 'testweb/';
266
- // TODO separate options?
267
- options.sourceMap = options;
268
-
272
+ options.sourceMap = {
273
+ sourceMapOutputFilename: name + '.css',
274
+ sourceMapBasepath: path.join(process.cwd(), baseFolder),
275
+ sourceMapRootpath: 'testweb/'
276
+ };
269
277
  // This options is normally set by the bin/lessc script. Setting it causes the sourceMappingURL comment to be appended to the CSS
270
278
  // output. The value is designed to allow the sourceMapBasepath option to be tested, as it should be removed by less before
271
279
  // setting the sourceMappingURL value, leaving just the sourceMapOutputFilename and .map extension.
272
- options.sourceMapFilename = options.sourceMapBasepath + '/' + options.sourceMapOutputFilename + '.map';
280
+ options.sourceMap.sourceMapFilename = options.sourceMap.sourceMapBasepath + '/' + options.sourceMap.sourceMapOutputFilename + '.map';
273
281
  }
274
282
 
275
283
  options.getVars = function(file) {
276
- return JSON.parse(fs.readFileSync(getFilename(getBasename(file), 'vars', baseFolder), 'utf8'));
284
+ try {
285
+ return JSON.parse(fs.readFileSync(getFilename(getBasename(file), 'vars', baseFolder), 'utf8'));
286
+ }
287
+ catch (e) {
288
+ return {};
289
+ }
277
290
  };
278
291
 
279
292
  var doubleCallCheck = false;
@@ -294,6 +307,7 @@ module.exports = function() {
294
307
  release();
295
308
  return verificationResult;
296
309
  }
310
+
297
311
  if (err) {
298
312
  fail('ERROR: ' + (err && err.message));
299
313
  if (isVerbose) {
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["testweb/sourcemaps/custom-props.less"],"names":[],"mappings":"AAEA;EACC,uBAHO,UAGP;EACA,OAAO,eAAP;EACA,gCAAA","file":"sourcemaps/custom-props.css"}
@@ -1,4 +0,0 @@
1
- .a {
2
- @wrongHEXColorCode: #DCALLB;
3
- color: @wrongHEXColorCode;
4
- }
@@ -1,4 +0,0 @@
1
- SyntaxError: Invalid HEX color code in {path}color-invalid-hex-code.less on line 2, column 29:
2
- 1 .a {
3
- 2 @wrongHEXColorCode: #DCALLB;
4
- 3 color: @wrongHEXColorCode;
@@ -1,4 +0,0 @@
1
- .a {
2
- @wrongHEXColorCode: #fffblack;
3
- color: @wrongHEXColorCode;
4
- }
@@ -1,4 +0,0 @@
1
- SyntaxError: Invalid HEX color code in {path}color-invalid-hex-code2.less on line 2, column 29:
2
- 1 .a {
3
- 2 @wrongHEXColorCode: #fffblack;
4
- 3 color: @wrongHEXColorCode;
@@ -1,4 +0,0 @@
1
- .a {
2
- @wrongHEXColorCode: #DCALLB;
3
- color: @wrongHEXColorCode;
4
- }
@@ -1,4 +0,0 @@
1
- SyntaxError: Invalid HEX color code in {path}color-invalid-hex-code.less on line 2, column 29:
2
- 1 .a {
3
- 2 @wrongHEXColorCode: #DCALLB;
4
- 3 color: @wrongHEXColorCode;
@@ -1,4 +0,0 @@
1
- .a {
2
- @wrongHEXColorCode: #fffblack;
3
- color: @wrongHEXColorCode;
4
- }
@@ -1,4 +0,0 @@
1
- SyntaxError: Invalid HEX color code in {path}color-invalid-hex-code2.less on line 2, column 29:
2
- 1 .a {
3
- 2 @wrongHEXColorCode: #fffblack;
4
- 3 color: @wrongHEXColorCode;