less 4.1.2 → 4.1.3

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/Gruntfile.js CHANGED
@@ -261,6 +261,7 @@ module.exports = function(grunt) {
261
261
  `node bin/lessc --clean-css="--s1 --advanced" ${lessFolder}/_main/lazy-eval.less tmp/lazy-eval.css`,
262
262
  "cd lib",
263
263
  `node ../bin/lessc --clean-css="--s1 --advanced" ../${lessFolder}/_main/lazy-eval.less ../tmp/lazy-eval.css`,
264
+ `node ../bin/lessc --source-map=lazy-eval.css.map --autoprefix ../${lessFolder}/_main/lazy-eval.less ../tmp/lazy-eval.css`,
264
265
  "cd ..",
265
266
  // Test multiple plugins
266
267
  `node bin/lessc --plugin=clean-css="--s1 --advanced" --plugin=autoprefix="ie 11,Edge >= 13,Chrome >= 47,Firefox >= 45,iOS >= 9.2,Safari >= 9" ${lessFolder}/_main/lazy-eval.less tmp/lazy-eval.css`
package/bin/lessc CHANGED
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env node
2
+
3
+ /* eslint indent: [2, 2, {"SwitchCase": 1}] */
4
+
2
5
  "use strict";
3
6
 
4
7
  var path = require('path');
@@ -87,6 +90,12 @@ function render() {
87
90
  output = path.resolve(process.cwd(), output);
88
91
  }
89
92
 
93
+ if (options.disablePluginRule && queuePlugins.length > 0) {
94
+ console.error('--plugin and --disable-plugin-rule may not be used at the same time');
95
+ process.exitCode = 1;
96
+ return;
97
+ }
98
+
90
99
  if (options.sourceMap) {
91
100
  sourceMapOptions.sourceMapInputFilename = input;
92
101
 
@@ -113,6 +122,7 @@ function render() {
113
122
  var mapDir = path.dirname(mapFilename);
114
123
  var outputDir = path.dirname(output); // find the path from the map to the output file
115
124
 
125
+ // eslint-disable-next-line max-len
116
126
  sourceMapOptions.sourceMapOutputFilename = path.join(path.relative(mapDir, outputDir), path.basename(output)); // make the sourcemap filename point to the sourcemap relative to the css file output directory
117
127
 
118
128
  sourceMapOptions.sourceMapFilename = path.join(path.relative(outputDir, mapDir), path.basename(sourceMapOptions.sourceMapFullFilename));
@@ -180,6 +190,9 @@ function render() {
180
190
  var filename = sourceMapOptions.sourceMapFullFilename;
181
191
  ensureDirectory(filename);
182
192
 
193
+ // To fix https://github.com/less/less.js/issues/3646
194
+ output = output.toString();
195
+
183
196
  fs.writeFile(filename, output, 'utf8', function (err) {
184
197
  if (err) {
185
198
  var description = 'Error: ';
@@ -441,7 +454,8 @@ function processPluginQueue() {
441
454
  break;
442
455
 
443
456
  case 'no-js':
444
- console.error('The "--no-js" argument is deprecated, as inline JavaScript ' + 'is disabled by default. Use "--js" to enable inline JavaScript (not recommended).');
457
+ // eslint-disable-next-line max-len
458
+ console.error('The "--no-js" argument is deprecated, as inline JavaScript is disabled by default. Use "--js" to enable inline JavaScript (not recommended).');
445
459
  break;
446
460
 
447
461
  case 'include-path':
@@ -626,6 +640,10 @@ function processPluginQueue() {
626
640
  });
627
641
  break;
628
642
 
643
+ case 'disable-plugin-rule':
644
+ options.disablePluginRule = true;
645
+ break;
646
+
629
647
  default:
630
648
  queuePlugins.push({
631
649
  name: arg,
package/dist/less.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Less - Leaner CSS v4.1.2
2
+ * Less - Leaner CSS v4.1.3
3
3
  * http://lesscss.org
4
4
  *
5
- * Copyright (c) 2009-2021, Alexis Sellier <self@cloudhead.net>
5
+ * Copyright (c) 2009-2022, Alexis Sellier <self@cloudhead.net>
6
6
  * Licensed under the Apache-2.0 License.
7
7
  *
8
8
  * @license Apache-2.0
@@ -80,6 +80,9 @@
80
80
  .replace(/\./g, ':'); // Replace dots with colons(for valid id)
81
81
  }
82
82
  function addDataAttr(options, tag) {
83
+ if (!tag) {
84
+ return;
85
+ } // in case of tag is null or undefined
83
86
  for (var opt in tag.dataset) {
84
87
  if (tag.dataset.hasOwnProperty(opt)) {
85
88
  if (opt === 'env' || opt === 'dumpLineNumbers' || opt === 'rootpath' || opt === 'errorReporting') {
@@ -1599,41 +1602,38 @@
1599
1602
  }
1600
1603
  });
1601
1604
 
1602
- var debugInfo = /** @class */ (function () {
1603
- function debugInfo(context, ctx, lineSeparator) {
1604
- var result = '';
1605
- if (context.dumpLineNumbers && !context.compress) {
1606
- switch (context.dumpLineNumbers) {
1607
- case 'comments':
1608
- result = debugInfo.asComment(ctx);
1609
- break;
1610
- case 'mediaquery':
1611
- result = debugInfo.asMediaQuery(ctx);
1612
- break;
1613
- case 'all':
1614
- result = debugInfo.asComment(ctx) + (lineSeparator || '') + debugInfo.asMediaQuery(ctx);
1615
- break;
1616
- }
1617
- }
1618
- return result;
1605
+ function asComment(ctx) {
1606
+ return "/* line " + ctx.debugInfo.lineNumber + ", " + ctx.debugInfo.fileName + " */\n";
1607
+ }
1608
+ function asMediaQuery(ctx) {
1609
+ var filenameWithProtocol = ctx.debugInfo.fileName;
1610
+ if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) {
1611
+ filenameWithProtocol = "file://" + filenameWithProtocol;
1619
1612
  }
1620
- debugInfo.asComment = function (ctx) {
1621
- return "/* line " + ctx.debugInfo.lineNumber + ", " + ctx.debugInfo.fileName + " */\n";
1622
- };
1623
- debugInfo.asMediaQuery = function (ctx) {
1624
- var filenameWithProtocol = ctx.debugInfo.fileName;
1625
- if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) {
1626
- filenameWithProtocol = "file://" + filenameWithProtocol;
1613
+ return "@media -sass-debug-info{filename{font-family:" + filenameWithProtocol.replace(/([.:\/\\])/g, function (a) {
1614
+ if (a == '\\') {
1615
+ a = '\/';
1627
1616
  }
1628
- return "@media -sass-debug-info{filename{font-family:" + filenameWithProtocol.replace(/([.:\/\\])/g, function (a) {
1629
- if (a == '\\') {
1630
- a = '\/';
1631
- }
1632
- return "\\" + a;
1633
- }) + "}line{font-family:\\00003" + ctx.debugInfo.lineNumber + "}}\n";
1634
- };
1635
- return debugInfo;
1636
- }());
1617
+ return "\\" + a;
1618
+ }) + "}line{font-family:\\00003" + ctx.debugInfo.lineNumber + "}}\n";
1619
+ }
1620
+ function debugInfo(context, ctx, lineSeparator) {
1621
+ var result = '';
1622
+ if (context.dumpLineNumbers && !context.compress) {
1623
+ switch (context.dumpLineNumbers) {
1624
+ case 'comments':
1625
+ result = asComment(ctx);
1626
+ break;
1627
+ case 'mediaquery':
1628
+ result = asMediaQuery(ctx);
1629
+ break;
1630
+ case 'all':
1631
+ result = asComment(ctx) + (lineSeparator || '') + asMediaQuery(ctx);
1632
+ break;
1633
+ }
1634
+ }
1635
+ return result;
1636
+ }
1637
1637
 
1638
1638
  var Comment = function (value, isLineComment, index, currentFileInfo) {
1639
1639
  this.value = value;
@@ -3387,15 +3387,16 @@
3387
3387
  }
3388
3388
  });
3389
3389
 
3390
- var Attribute = function (key, op, value) {
3390
+ var Attribute = function (key, op, value, cif) {
3391
3391
  this.key = key;
3392
3392
  this.op = op;
3393
3393
  this.value = value;
3394
+ this.cif = cif;
3394
3395
  };
3395
3396
  Attribute.prototype = Object.assign(new Node(), {
3396
3397
  type: 'Attribute',
3397
3398
  eval: function (context) {
3398
- return new Attribute(this.key.eval ? this.key.eval(context) : this.key, this.op, (this.value && this.value.eval) ? this.value.eval(context) : this.value);
3399
+ return new Attribute(this.key.eval ? this.key.eval(context) : this.key, this.op, (this.value && this.value.eval) ? this.value.eval(context) : this.value, this.cif);
3399
3400
  },
3400
3401
  genCSS: function (context, output) {
3401
3402
  output.add(this.toCSS(context));
@@ -3406,6 +3407,9 @@
3406
3407
  value += this.op;
3407
3408
  value += (this.value.toCSS ? this.value.toCSS(context) : this.value);
3408
3409
  }
3410
+ if (this.cif) {
3411
+ value = value + " " + this.cif;
3412
+ }
3409
3413
  return "[" + value + "]";
3410
3414
  }
3411
3415
  });
@@ -6654,11 +6658,20 @@
6654
6658
  //
6655
6659
  parse: function (str, callback, additionalData) {
6656
6660
  var root;
6657
- var error = null;
6661
+ var err = null;
6658
6662
  var globalVars;
6659
6663
  var modifyVars;
6660
6664
  var ignored;
6661
6665
  var preText = '';
6666
+ // Optionally disable @plugin parsing
6667
+ if (additionalData && additionalData.disablePluginRule) {
6668
+ parsers.plugin = function () {
6669
+ var dir = parserInput.$re(/^@plugin?\s+/);
6670
+ if (dir) {
6671
+ error('@plugin statements are not allowed when disablePluginRule is set to true');
6672
+ }
6673
+ };
6674
+ }
6662
6675
  globalVars = (additionalData && additionalData.globalVars) ? Parser.serializeVars(additionalData.globalVars) + "\n" : '';
6663
6676
  modifyVars = (additionalData && additionalData.modifyVars) ? "\n" + Parser.serializeVars(additionalData.modifyVars) : '';
6664
6677
  if (context.pluginManager) {
@@ -6723,7 +6736,7 @@
6723
6736
  message += '. Possibly missing something';
6724
6737
  }
6725
6738
  }
6726
- error = new LessError({
6739
+ err = new LessError({
6727
6740
  type: 'Parse',
6728
6741
  message: message,
6729
6742
  index: endInfo.furthest,
@@ -6731,7 +6744,7 @@
6731
6744
  }, imports);
6732
6745
  }
6733
6746
  var finish = function (e) {
6734
- e = error || e || imports.error;
6747
+ e = err || e || imports.error;
6735
6748
  if (e) {
6736
6749
  if (!(e instanceof LessError)) {
6737
6750
  e = new LessError(e, imports, fileInfo.filename);
@@ -7808,15 +7821,23 @@
7808
7821
  var key;
7809
7822
  var val;
7810
7823
  var op;
7824
+ //
7825
+ // case-insensitive flag
7826
+ // e.g. [attr operator value i]
7827
+ //
7828
+ var cif;
7811
7829
  if (!(key = entities.variableCurly())) {
7812
7830
  key = expect(/^(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/);
7813
7831
  }
7814
7832
  op = parserInput.$re(/^[|~*$^]?=/);
7815
7833
  if (op) {
7816
7834
  val = entities.quoted() || parserInput.$re(/^[0-9]+%/) || parserInput.$re(/^[\w-]+/) || entities.variableCurly();
7835
+ if (val) {
7836
+ cif = parserInput.$re(/^[iIsS]/);
7837
+ }
7817
7838
  }
7818
7839
  expectChar(']');
7819
- return new (tree.Attribute)(key, op, val);
7840
+ return new (tree.Attribute)(key, op, val, cif);
7820
7841
  },
7821
7842
  //
7822
7843
  // The `block` rule is used by `ruleset` and `mixin.definition`.
@@ -8063,7 +8084,7 @@
8063
8084
  var path;
8064
8085
  var features;
8065
8086
  var index = parserInput.i;
8066
- var dir = parserInput.$re(/^@import?\s+/);
8087
+ var dir = parserInput.$re(/^@import\s+/);
8067
8088
  if (dir) {
8068
8089
  var options = (dir ? this.importOptions() : null) || {};
8069
8090
  if ((path = this.entities.quoted() || this.entities.url())) {
@@ -8214,7 +8235,7 @@
8214
8235
  var args;
8215
8236
  var options;
8216
8237
  var index = parserInput.i;
8217
- var dir = parserInput.$re(/^@plugin?\s+/);
8238
+ var dir = parserInput.$re(/^@plugin\s+/);
8218
8239
  if (dir) {
8219
8240
  args = this.pluginArgs();
8220
8241
  if (args) {
@@ -10575,7 +10596,7 @@
10575
10596
  return render;
10576
10597
  }
10577
10598
 
10578
- var version = "4.1.2";
10599
+ var version = "4.1.3";
10579
10600
 
10580
10601
  function parseNodeVersion(version) {
10581
10602
  var match = version.match(/^v(\d{1,2})\.(\d{1,2})\.(\d{1,2})(?:-([0-9A-Za-z-.]+))?(?:\+([0-9A-Za-z-.]+))?$/); // eslint-disable-line max-len