less 4.1.0 → 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.
Files changed (52) hide show
  1. package/.eslintignore +2 -1
  2. package/.eslintrc.json +70 -2
  3. package/Gruntfile.js +7 -11
  4. package/bin/lessc +19 -1
  5. package/dist/less.js +232 -146
  6. package/dist/less.min.js +3 -3
  7. package/dist/less.min.js.map +1 -1
  8. package/lib/less/functions/function-caller.js +5 -1
  9. package/lib/less/functions/function-caller.js.map +1 -1
  10. package/lib/less/functions/types.js +2 -1
  11. package/lib/less/functions/types.js.map +1 -1
  12. package/lib/less/parser/parser.js +24 -6
  13. package/lib/less/parser/parser.js.map +1 -1
  14. package/lib/less/tree/attribute.js +6 -2
  15. package/lib/less/tree/attribute.js.map +1 -1
  16. package/lib/less/tree/debug-info.js +30 -33
  17. package/lib/less/tree/debug-info.js.map +1 -1
  18. package/lib/less/tree/dimension.js +2 -1
  19. package/lib/less/tree/dimension.js.map +1 -1
  20. package/lib/less/tree/expression.js +0 -2
  21. package/lib/less/tree/expression.js.map +1 -1
  22. package/lib/less/tree/index.js +34 -7
  23. package/lib/less/tree/index.js.map +1 -1
  24. package/lib/less/tree/js-eval-node.js +4 -2
  25. package/lib/less/tree/js-eval-node.js.map +1 -1
  26. package/lib/less/tree/mixin-call.js +9 -3
  27. package/lib/less/tree/mixin-call.js.map +1 -1
  28. package/lib/less/tree/namespace-value.js +6 -2
  29. package/lib/less/tree/namespace-value.js.map +1 -1
  30. package/lib/less/tree/node.js +14 -7
  31. package/lib/less/tree/node.js.map +1 -1
  32. package/lib/less/tree/operation.js +3 -2
  33. package/lib/less/tree/operation.js.map +1 -1
  34. package/lib/less/tree/property.js +6 -2
  35. package/lib/less/tree/property.js.map +1 -1
  36. package/lib/less/tree/variable.js +6 -2
  37. package/lib/less/tree/variable.js.map +1 -1
  38. package/lib/less/visitors/to-css-visitor.js +4 -2
  39. package/lib/less/visitors/to-css-visitor.js.map +1 -1
  40. package/lib/less-browser/utils.js +3 -0
  41. package/lib/less-browser/utils.js.map +1 -1
  42. package/lib/less-node/image-size.js +0 -2
  43. package/lib/less-node/image-size.js.map +1 -1
  44. package/lib/less-node/index.js.map +1 -1
  45. package/lib/less-node/lessc-helper.js +1 -0
  46. package/lib/less-node/lessc-helper.js.map +1 -1
  47. package/lib/less-node/url-file-manager.js +3 -3
  48. package/lib/less-node/url-file-manager.js.map +1 -1
  49. package/package.json +11 -10
  50. package/test/index.js +3 -1
  51. package/test/less-test.js +45 -1
  52. package/tsconfig.json +5 -0
package/dist/less.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Less - Leaner CSS v4.1.0
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') {
@@ -191,7 +194,7 @@
191
194
  }
192
195
  });
193
196
 
194
- var logger = {
197
+ var logger$1 = {
195
198
  error: function (msg) {
196
199
  this._fireEvent('error', msg);
197
200
  },
@@ -250,10 +253,10 @@
250
253
  }
251
254
  Environment.prototype.getFileManager = function (filename, currentDirectory, options, environment, isSync) {
252
255
  if (!filename) {
253
- logger.warn('getFileManager called with no filename.. Please report this issue. continuing.');
256
+ logger$1.warn('getFileManager called with no filename.. Please report this issue. continuing.');
254
257
  }
255
258
  if (currentDirectory == null) {
256
- logger.warn('getFileManager called with null directory.. Please report this issue. continuing.');
259
+ logger$1.warn('getFileManager called with null directory.. Please report this issue. continuing.');
257
260
  }
258
261
  var fileManagers = this.fileManagers;
259
262
  if (options.pluginManager) {
@@ -464,14 +467,21 @@
464
467
  this.nodeVisible = undefined;
465
468
  this.rootNode = null;
466
469
  this.parsed = null;
467
- var self = this;
468
- Object.defineProperty(this, 'currentFileInfo', {
469
- get: function () { return self.fileInfo(); }
470
- });
471
- Object.defineProperty(this, 'index', {
472
- get: function () { return self.getIndex(); }
473
- });
474
470
  }
471
+ Object.defineProperty(Node.prototype, "currentFileInfo", {
472
+ get: function () {
473
+ return this.fileInfo();
474
+ },
475
+ enumerable: false,
476
+ configurable: true
477
+ });
478
+ Object.defineProperty(Node.prototype, "index", {
479
+ get: function () {
480
+ return this.getIndex();
481
+ },
482
+ enumerable: false,
483
+ configurable: true
484
+ });
475
485
  Node.prototype.setParent = function (nodes, parent) {
476
486
  function set(node) {
477
487
  if (node && node instanceof Node) {
@@ -703,11 +713,11 @@
703
713
  switch (colorFunction) {
704
714
  case 'rgba':
705
715
  args = this.rgb.map(function (c) {
706
- return clamp(Math.round(c), 255);
707
- }).concat(clamp(alpha, 1));
716
+ return clamp$1(Math.round(c), 255);
717
+ }).concat(clamp$1(alpha, 1));
708
718
  break;
709
719
  case 'hsla':
710
- args.push(clamp(alpha, 1));
720
+ args.push(clamp$1(alpha, 1));
711
721
  case 'hsl':
712
722
  color = this.toHSL();
713
723
  args = [
@@ -832,12 +842,12 @@
832
842
  return c;
833
843
  }
834
844
  };
835
- function clamp(v, max) {
845
+ function clamp$1(v, max) {
836
846
  return Math.min(Math.max(v, 0), max);
837
847
  }
838
848
  function toHex(v) {
839
849
  return "#" + v.map(function (c) {
840
- c = clamp(Math.round(c), 255);
850
+ c = clamp$1(Math.round(c), 255);
841
851
  return (c < 16 ? '0' : '') + c.toString(16);
842
852
  }).join('');
843
853
  }
@@ -1507,7 +1517,7 @@
1507
1517
  }
1508
1518
  });
1509
1519
 
1510
- var MATH = Math$1;
1520
+ var MATH$1 = Math$1;
1511
1521
  function evalName(context, name) {
1512
1522
  var value = '';
1513
1523
  var i;
@@ -1555,10 +1565,10 @@
1555
1565
  variable = false; // never treat expanded interpolation as new variable name
1556
1566
  }
1557
1567
  // @todo remove when parens-division is default
1558
- if (name === 'font' && context.math === MATH.ALWAYS) {
1568
+ if (name === 'font' && context.math === MATH$1.ALWAYS) {
1559
1569
  mathBypass = true;
1560
1570
  prevMath = context.math;
1561
- context.math = MATH.PARENS_DIVISION;
1571
+ context.math = MATH$1.PARENS_DIVISION;
1562
1572
  }
1563
1573
  try {
1564
1574
  context.importantScope.push({});
@@ -1592,41 +1602,38 @@
1592
1602
  }
1593
1603
  });
1594
1604
 
1595
- var debugInfo = /** @class */ (function () {
1596
- function debugInfo(context, ctx, lineSeparator) {
1597
- var result = '';
1598
- if (context.dumpLineNumbers && !context.compress) {
1599
- switch (context.dumpLineNumbers) {
1600
- case 'comments':
1601
- result = debugInfo.asComment(ctx);
1602
- break;
1603
- case 'mediaquery':
1604
- result = debugInfo.asMediaQuery(ctx);
1605
- break;
1606
- case 'all':
1607
- result = debugInfo.asComment(ctx) + (lineSeparator || '') + debugInfo.asMediaQuery(ctx);
1608
- break;
1609
- }
1610
- }
1611
- 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;
1612
1612
  }
1613
- debugInfo.asComment = function (ctx) {
1614
- return "/* line " + ctx.debugInfo.lineNumber + ", " + ctx.debugInfo.fileName + " */\n";
1615
- };
1616
- debugInfo.asMediaQuery = function (ctx) {
1617
- var filenameWithProtocol = ctx.debugInfo.fileName;
1618
- if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) {
1619
- filenameWithProtocol = "file://" + filenameWithProtocol;
1613
+ return "@media -sass-debug-info{filename{font-family:" + filenameWithProtocol.replace(/([.:\/\\])/g, function (a) {
1614
+ if (a == '\\') {
1615
+ a = '\/';
1620
1616
  }
1621
- return "@media -sass-debug-info{filename{font-family:" + filenameWithProtocol.replace(/([.:\/\\])/g, function (a) {
1622
- if (a == '\\') {
1623
- a = '\/';
1624
- }
1625
- return "\\" + a;
1626
- }) + "}line{font-family:\\00003" + ctx.debugInfo.lineNumber + "}}\n";
1627
- };
1628
- return debugInfo;
1629
- }());
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
+ }
1630
1637
 
1631
1638
  var Comment = function (value, isLineComment, index, currentFileInfo) {
1632
1639
  this.value = value;
@@ -2890,7 +2897,8 @@
2890
2897
  // so `1px + 2` will yield `3px`.
2891
2898
  operate: function (context, op, other) {
2892
2899
  /* jshint noempty:false */
2893
- var value = this._operate(context, op, this.value, other.value), unit = this.unit.clone();
2900
+ var value = this._operate(context, op, this.value, other.value);
2901
+ var unit = this.unit.clone();
2894
2902
  if (op === '+' || op === '-') {
2895
2903
  if (unit.numerator.length === 0 && unit.denominator.length === 0) {
2896
2904
  unit = other.unit.clone();
@@ -2984,7 +2992,7 @@
2984
2992
  }
2985
2993
  });
2986
2994
 
2987
- var MATH$1 = Math$1;
2995
+ var MATH = Math$1;
2988
2996
  var Operation = function (op, operands, isSpaced) {
2989
2997
  this.op = op.trim();
2990
2998
  this.operands = operands;
@@ -3005,8 +3013,9 @@
3005
3013
  if (b instanceof Dimension && a instanceof Color) {
3006
3014
  b = b.toColor();
3007
3015
  }
3008
- if (!a.operate) {
3009
- if (a instanceof Operation && a.op === '/' && context.math === MATH$1.PARENS_DIVISION) {
3016
+ if (!a.operate || !b.operate) {
3017
+ if ((a instanceof Operation || b instanceof Operation)
3018
+ && a.op === '/' && context.math === MATH.PARENS_DIVISION) {
3010
3019
  return new Operation(this.op, [a, b], this.isSpaced);
3011
3020
  }
3012
3021
  throw { type: 'Operation',
@@ -3046,12 +3055,14 @@
3046
3055
  PERFORMANCE OF THIS SOFTWARE.
3047
3056
  ***************************************************************************** */
3048
3057
 
3049
- function __spreadArrays$1() {
3050
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
3051
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
3052
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
3053
- r[k] = a[j];
3054
- return r;
3058
+ function __spreadArray(to, from, pack) {
3059
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3060
+ if (ar || !(i in from)) {
3061
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
3062
+ ar[i] = from[i];
3063
+ }
3064
+ }
3065
+ return to.concat(ar || from);
3055
3066
  }
3056
3067
 
3057
3068
  var Expression = function (value, noSpacing) {
@@ -3144,6 +3155,10 @@
3144
3155
  if (item.type === 'Expression') {
3145
3156
  var subNodes = item.value.filter(commentFilter);
3146
3157
  if (subNodes.length === 1) {
3158
+ // https://github.com/less/less.js/issues/3616
3159
+ if (item.parens && subNodes[0].op === '/') {
3160
+ return item;
3161
+ }
3147
3162
  return subNodes[0];
3148
3163
  }
3149
3164
  else {
@@ -3153,7 +3168,7 @@
3153
3168
  return item;
3154
3169
  });
3155
3170
  if (evalArgs === false) {
3156
- return this.func.apply(this, __spreadArrays$1([this.context], args));
3171
+ return this.func.apply(this, __spreadArray([this.context], args));
3157
3172
  }
3158
3173
  return this.func.apply(this, args);
3159
3174
  };
@@ -3269,7 +3284,9 @@
3269
3284
  name = "@" + new Variable(name.slice(1), this.getIndex(), this.fileInfo()).eval(context).value;
3270
3285
  }
3271
3286
  if (this.evaluating) {
3272
- throw { type: 'Name', message: "Recursive variable definition for " + name, filename: this.fileInfo().filename,
3287
+ throw { type: 'Name',
3288
+ message: "Recursive variable definition for " + name,
3289
+ filename: this.fileInfo().filename,
3273
3290
  index: this.getIndex() };
3274
3291
  }
3275
3292
  this.evaluating = true;
@@ -3294,7 +3311,9 @@
3294
3311
  return variable;
3295
3312
  }
3296
3313
  else {
3297
- throw { type: 'Name', message: "variable " + name + " is undefined", filename: this.fileInfo().filename,
3314
+ throw { type: 'Name',
3315
+ message: "variable " + name + " is undefined",
3316
+ filename: this.fileInfo().filename,
3298
3317
  index: this.getIndex() };
3299
3318
  }
3300
3319
  },
@@ -3322,7 +3341,9 @@
3322
3341
  // TODO: shorten this reference
3323
3342
  var mergeRules = context.pluginManager.less.visitors.ToCSSVisitor.prototype._mergeRules;
3324
3343
  if (this.evaluating) {
3325
- throw { type: 'Name', message: "Recursive property reference for " + name, filename: this.fileInfo().filename,
3344
+ throw { type: 'Name',
3345
+ message: "Recursive property reference for " + name,
3346
+ filename: this.fileInfo().filename,
3326
3347
  index: this.getIndex() };
3327
3348
  }
3328
3349
  this.evaluating = true;
@@ -3349,7 +3370,9 @@
3349
3370
  return property;
3350
3371
  }
3351
3372
  else {
3352
- throw { type: 'Name', message: "Property '" + name + "' is undefined", filename: this.currentFileInfo.filename,
3373
+ throw { type: 'Name',
3374
+ message: "Property '" + name + "' is undefined",
3375
+ filename: this.currentFileInfo.filename,
3353
3376
  index: this.index };
3354
3377
  }
3355
3378
  },
@@ -3364,15 +3387,16 @@
3364
3387
  }
3365
3388
  });
3366
3389
 
3367
- var Attribute = function (key, op, value) {
3390
+ var Attribute = function (key, op, value, cif) {
3368
3391
  this.key = key;
3369
3392
  this.op = op;
3370
3393
  this.value = value;
3394
+ this.cif = cif;
3371
3395
  };
3372
3396
  Attribute.prototype = Object.assign(new Node(), {
3373
3397
  type: 'Attribute',
3374
3398
  eval: function (context) {
3375
- 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);
3376
3400
  },
3377
3401
  genCSS: function (context, output) {
3378
3402
  output.add(this.toCSS(context));
@@ -3383,6 +3407,9 @@
3383
3407
  value += this.op;
3384
3408
  value += (this.value.toCSS ? this.value.toCSS(context) : this.value);
3385
3409
  }
3410
+ if (this.cif) {
3411
+ value = value + " " + this.cif;
3412
+ }
3386
3413
  return "[" + value + "]";
3387
3414
  }
3388
3415
  });
@@ -3797,7 +3824,8 @@
3797
3824
  expression = new Function("return (" + expression + ")");
3798
3825
  }
3799
3826
  catch (e) {
3800
- throw { message: "JavaScript evaluation error: " + e.message + " from `" + expression + "`", filename: this.fileInfo().filename,
3827
+ throw { message: "JavaScript evaluation error: " + e.message + " from `" + expression + "`",
3828
+ filename: this.fileInfo().filename,
3801
3829
  index: this.getIndex() };
3802
3830
  }
3803
3831
  var variables = context.frames[0].variables();
@@ -3816,7 +3844,8 @@
3816
3844
  result = expression.call(evalContext);
3817
3845
  }
3818
3846
  catch (e) {
3819
- throw { message: "JavaScript evaluation error: '" + e.name + ": " + e.message.replace(/["]/g, '\'') + "'", filename: this.fileInfo().filename,
3847
+ throw { message: "JavaScript evaluation error: '" + e.name + ": " + e.message.replace(/["]/g, '\'') + "'",
3848
+ filename: this.fileInfo().filename,
3820
3849
  index: this.getIndex() };
3821
3850
  }
3822
3851
  return result;
@@ -4057,7 +4086,9 @@
4057
4086
  rules = rules.variable(name);
4058
4087
  }
4059
4088
  if (!rules) {
4060
- throw { type: 'Name', message: "variable " + name + " not found", filename: this.fileInfo().filename,
4089
+ throw { type: 'Name',
4090
+ message: "variable " + name + " not found",
4091
+ filename: this.fileInfo().filename,
4061
4092
  index: this.getIndex() };
4062
4093
  }
4063
4094
  }
@@ -4072,7 +4103,9 @@
4072
4103
  rules = rules.property(name);
4073
4104
  }
4074
4105
  if (!rules) {
4075
- throw { type: 'Name', message: "property \"" + name.substr(1) + "\" not found", filename: this.fileInfo().filename,
4106
+ throw { type: 'Name',
4107
+ message: "property \"" + name.substr(1) + "\" not found",
4108
+ filename: this.fileInfo().filename,
4076
4109
  index: this.getIndex() };
4077
4110
  }
4078
4111
  // Properties are an array of values, since a ruleset can have multiple props.
@@ -4413,7 +4446,9 @@
4413
4446
  else {
4414
4447
  defaultResult = defTrue;
4415
4448
  if ((count[defTrue] + count[defFalse]) > 1) {
4416
- throw { type: 'Runtime', message: "Ambiguous use of `default()` found when matching for `" + this.format(args) + "`", index: this.getIndex(), filename: this.fileInfo().filename };
4449
+ throw { type: 'Runtime',
4450
+ message: "Ambiguous use of `default()` found when matching for `" + this.format(args) + "`",
4451
+ index: this.getIndex(), filename: this.fileInfo().filename };
4417
4452
  }
4418
4453
  }
4419
4454
  for (m = 0; m < candidates.length; m++) {
@@ -4441,10 +4476,14 @@
4441
4476
  }
4442
4477
  }
4443
4478
  if (isOneFound) {
4444
- throw { type: 'Runtime', message: "No matching definition was found for `" + this.format(args) + "`", index: this.getIndex(), filename: this.fileInfo().filename };
4479
+ throw { type: 'Runtime',
4480
+ message: "No matching definition was found for `" + this.format(args) + "`",
4481
+ index: this.getIndex(), filename: this.fileInfo().filename };
4445
4482
  }
4446
4483
  else {
4447
- throw { type: 'Name', message: this.selector.toCSS().trim() + " is undefined", index: this.getIndex(), filename: this.fileInfo().filename };
4484
+ throw { type: 'Name',
4485
+ message: this.selector.toCSS().trim() + " is undefined",
4486
+ index: this.getIndex(), filename: this.fileInfo().filename };
4448
4487
  }
4449
4488
  },
4450
4489
  _setVisibilityToReplacement: function (replacement) {
@@ -4474,13 +4513,40 @@
4474
4513
  });
4475
4514
 
4476
4515
  var tree = {
4477
- Node: Node, Color: Color, AtRule: AtRule, DetachedRuleset: DetachedRuleset, Operation: Operation,
4478
- Dimension: Dimension, Unit: Unit, Keyword: Keyword, Variable: Variable, Property: Property,
4479
- Ruleset: Ruleset, Element: Element, Attribute: Attribute, Combinator: Combinator, Selector: Selector,
4480
- Quoted: Quoted, Expression: Expression, Declaration: Declaration, Call: Call, URL: URL, Import: Import,
4481
- Comment: Comment, Anonymous: Anonymous, Value: Value, JavaScript: JavaScript, Assignment: Assignment,
4482
- Condition: Condition, Paren: Paren, Media: Media, UnicodeDescriptor: UnicodeDescriptor, Negative: Negative,
4483
- Extend: Extend, VariableCall: VariableCall, NamespaceValue: NamespaceValue,
4516
+ Node: Node,
4517
+ Color: Color,
4518
+ AtRule: AtRule,
4519
+ DetachedRuleset: DetachedRuleset,
4520
+ Operation: Operation,
4521
+ Dimension: Dimension,
4522
+ Unit: Unit,
4523
+ Keyword: Keyword,
4524
+ Variable: Variable,
4525
+ Property: Property,
4526
+ Ruleset: Ruleset,
4527
+ Element: Element,
4528
+ Attribute: Attribute,
4529
+ Combinator: Combinator,
4530
+ Selector: Selector,
4531
+ Quoted: Quoted,
4532
+ Expression: Expression,
4533
+ Declaration: Declaration,
4534
+ Call: Call,
4535
+ URL: URL,
4536
+ Import: Import,
4537
+ Comment: Comment,
4538
+ Anonymous: Anonymous,
4539
+ Value: Value,
4540
+ JavaScript: JavaScript,
4541
+ Assignment: Assignment,
4542
+ Condition: Condition,
4543
+ Paren: Paren,
4544
+ Media: Media,
4545
+ UnicodeDescriptor: UnicodeDescriptor,
4546
+ Negative: Negative,
4547
+ Extend: Extend,
4548
+ VariableCall: VariableCall,
4549
+ NamespaceValue: NamespaceValue,
4484
4550
  mixin: {
4485
4551
  Call: MixinCall,
4486
4552
  Definition: Definition
@@ -5278,7 +5344,7 @@
5278
5344
  catch (_) { }
5279
5345
  if (!indices[extend.index + " " + selector]) {
5280
5346
  indices[extend.index + " " + selector] = true;
5281
- logger.warn("extend '" + selector + "' has no matches");
5347
+ logger$1.warn("extend '" + selector + "' has no matches");
5282
5348
  }
5283
5349
  });
5284
5350
  };
@@ -5819,10 +5885,12 @@
5819
5885
  index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename };
5820
5886
  }
5821
5887
  if (ruleNode instanceof tree.Call) {
5822
- throw { message: "Function '" + ruleNode.name + "' did not return a root node", index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename };
5888
+ throw { message: "Function '" + ruleNode.name + "' did not return a root node",
5889
+ index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename };
5823
5890
  }
5824
5891
  if (ruleNode.type && !ruleNode.allowRoot) {
5825
- throw { message: ruleNode.type + " node returned by a function is not valid here", index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename };
5892
+ throw { message: ruleNode.type + " node returned by a function is not valid here",
5893
+ index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename };
5826
5894
  }
5827
5895
  }
5828
5896
  },
@@ -6590,11 +6658,20 @@
6590
6658
  //
6591
6659
  parse: function (str, callback, additionalData) {
6592
6660
  var root;
6593
- var error = null;
6661
+ var err = null;
6594
6662
  var globalVars;
6595
6663
  var modifyVars;
6596
6664
  var ignored;
6597
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
+ }
6598
6675
  globalVars = (additionalData && additionalData.globalVars) ? Parser.serializeVars(additionalData.globalVars) + "\n" : '';
6599
6676
  modifyVars = (additionalData && additionalData.modifyVars) ? "\n" + Parser.serializeVars(additionalData.modifyVars) : '';
6600
6677
  if (context.pluginManager) {
@@ -6659,7 +6736,7 @@
6659
6736
  message += '. Possibly missing something';
6660
6737
  }
6661
6738
  }
6662
- error = new LessError({
6739
+ err = new LessError({
6663
6740
  type: 'Parse',
6664
6741
  message: message,
6665
6742
  index: endInfo.furthest,
@@ -6667,7 +6744,7 @@
6667
6744
  }, imports);
6668
6745
  }
6669
6746
  var finish = function (e) {
6670
- e = error || e || imports.error;
6747
+ e = err || e || imports.error;
6671
6748
  if (e) {
6672
6749
  if (!(e instanceof LessError)) {
6673
6750
  e = new LessError(e, imports, fileInfo.filename);
@@ -7744,15 +7821,23 @@
7744
7821
  var key;
7745
7822
  var val;
7746
7823
  var op;
7824
+ //
7825
+ // case-insensitive flag
7826
+ // e.g. [attr operator value i]
7827
+ //
7828
+ var cif;
7747
7829
  if (!(key = entities.variableCurly())) {
7748
7830
  key = expect(/^(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/);
7749
7831
  }
7750
7832
  op = parserInput.$re(/^[|~*$^]?=/);
7751
7833
  if (op) {
7752
7834
  val = entities.quoted() || parserInput.$re(/^[0-9]+%/) || parserInput.$re(/^[\w-]+/) || entities.variableCurly();
7835
+ if (val) {
7836
+ cif = parserInput.$re(/^[iIsS]/);
7837
+ }
7753
7838
  }
7754
7839
  expectChar(']');
7755
- return new (tree.Attribute)(key, op, val);
7840
+ return new (tree.Attribute)(key, op, val, cif);
7756
7841
  },
7757
7842
  //
7758
7843
  // The `block` rule is used by `ruleset` and `mixin.definition`.
@@ -7999,7 +8084,7 @@
7999
8084
  var path;
8000
8085
  var features;
8001
8086
  var index = parserInput.i;
8002
- var dir = parserInput.$re(/^@import?\s+/);
8087
+ var dir = parserInput.$re(/^@import\s+/);
8003
8088
  if (dir) {
8004
8089
  var options = (dir ? this.importOptions() : null) || {};
8005
8090
  if ((path = this.entities.quoted() || this.entities.url())) {
@@ -8150,7 +8235,7 @@
8150
8235
  var args;
8151
8236
  var options;
8152
8237
  var index = parserInput.i;
8153
- var dir = parserInput.$re(/^@plugin?\s+/);
8238
+ var dir = parserInput.$re(/^@plugin\s+/);
8154
8239
  if (dir) {
8155
8240
  args = this.pluginArgs();
8156
8241
  if (args) {
@@ -8712,7 +8797,7 @@
8712
8797
  var boolean$1 = { isdefined: isdefined, boolean: boolean, 'if': If };
8713
8798
 
8714
8799
  var colorFunctions;
8715
- function clamp$1(val) {
8800
+ function clamp(val) {
8716
8801
  return Math.min(1, Math.max(0, val));
8717
8802
  }
8718
8803
  function hsla(origColor, hsl) {
@@ -8744,7 +8829,7 @@
8744
8829
  throw new Error('Argument cannot be evaluated to a color');
8745
8830
  }
8746
8831
  }
8747
- function number(n) {
8832
+ function number$1(n) {
8748
8833
  if (n instanceof Dimension) {
8749
8834
  return parseFloat(n.unit.is('%') ? n.value / 100 : n.value);
8750
8835
  }
@@ -8763,7 +8848,7 @@
8763
8848
  return parseFloat(n.value * size / 100);
8764
8849
  }
8765
8850
  else {
8766
- return number(n);
8851
+ return number$1(n);
8767
8852
  }
8768
8853
  }
8769
8854
  colorFunctions = {
@@ -8798,7 +8883,7 @@
8798
8883
  try {
8799
8884
  if (r instanceof Color) {
8800
8885
  if (g) {
8801
- a = number(g);
8886
+ a = number$1(g);
8802
8887
  }
8803
8888
  else {
8804
8889
  a = r.alpha;
@@ -8806,7 +8891,7 @@
8806
8891
  return new Color(r.rgb, a, 'rgba');
8807
8892
  }
8808
8893
  var rgb = [r, g, b].map(function (c) { return scaled(c, 255); });
8809
- a = number(a);
8894
+ a = number$1(a);
8810
8895
  return new Color(rgb, a, 'rgba');
8811
8896
  }
8812
8897
  catch (e) { }
@@ -8834,7 +8919,7 @@
8834
8919
  try {
8835
8920
  if (h instanceof Color) {
8836
8921
  if (s) {
8837
- a = number(s);
8922
+ a = number$1(s);
8838
8923
  }
8839
8924
  else {
8840
8925
  a = h.alpha;
@@ -8858,10 +8943,10 @@
8858
8943
  return m1_1;
8859
8944
  }
8860
8945
  }
8861
- h = (number(h) % 360) / 360;
8862
- s = clamp$1(number(s));
8863
- l = clamp$1(number(l));
8864
- a = clamp$1(number(a));
8946
+ h = (number$1(h) % 360) / 360;
8947
+ s = clamp(number$1(s));
8948
+ l = clamp(number$1(l));
8949
+ a = clamp(number$1(a));
8865
8950
  m2_1 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
8866
8951
  m1_1 = l * 2 - m2_1;
8867
8952
  var rgb = [
@@ -8869,7 +8954,7 @@
8869
8954
  hue(h) * 255,
8870
8955
  hue(h - 1 / 3) * 255
8871
8956
  ];
8872
- a = number(a);
8957
+ a = number$1(a);
8873
8958
  return new Color(rgb, a, 'hsla');
8874
8959
  }
8875
8960
  catch (e) { }
@@ -8878,10 +8963,10 @@
8878
8963
  return colorFunctions.hsva(h, s, v, 1.0);
8879
8964
  },
8880
8965
  hsva: function (h, s, v, a) {
8881
- h = ((number(h) % 360) / 360) * 360;
8882
- s = number(s);
8883
- v = number(v);
8884
- a = number(a);
8966
+ h = ((number$1(h) % 360) / 360) * 360;
8967
+ s = number$1(s);
8968
+ v = number$1(v);
8969
+ a = number$1(a);
8885
8970
  var i;
8886
8971
  var f;
8887
8972
  i = Math.floor((h / 60) % 6);
@@ -8950,7 +9035,7 @@
8950
9035
  else {
8951
9036
  hsl.s += amount.value / 100;
8952
9037
  }
8953
- hsl.s = clamp$1(hsl.s);
9038
+ hsl.s = clamp(hsl.s);
8954
9039
  return hsla(color, hsl);
8955
9040
  },
8956
9041
  desaturate: function (color, amount, method) {
@@ -8961,7 +9046,7 @@
8961
9046
  else {
8962
9047
  hsl.s -= amount.value / 100;
8963
9048
  }
8964
- hsl.s = clamp$1(hsl.s);
9049
+ hsl.s = clamp(hsl.s);
8965
9050
  return hsla(color, hsl);
8966
9051
  },
8967
9052
  lighten: function (color, amount, method) {
@@ -8972,7 +9057,7 @@
8972
9057
  else {
8973
9058
  hsl.l += amount.value / 100;
8974
9059
  }
8975
- hsl.l = clamp$1(hsl.l);
9060
+ hsl.l = clamp(hsl.l);
8976
9061
  return hsla(color, hsl);
8977
9062
  },
8978
9063
  darken: function (color, amount, method) {
@@ -8983,7 +9068,7 @@
8983
9068
  else {
8984
9069
  hsl.l -= amount.value / 100;
8985
9070
  }
8986
- hsl.l = clamp$1(hsl.l);
9071
+ hsl.l = clamp(hsl.l);
8987
9072
  return hsla(color, hsl);
8988
9073
  },
8989
9074
  fadein: function (color, amount, method) {
@@ -8994,7 +9079,7 @@
8994
9079
  else {
8995
9080
  hsl.a += amount.value / 100;
8996
9081
  }
8997
- hsl.a = clamp$1(hsl.a);
9082
+ hsl.a = clamp(hsl.a);
8998
9083
  return hsla(color, hsl);
8999
9084
  },
9000
9085
  fadeout: function (color, amount, method) {
@@ -9005,13 +9090,13 @@
9005
9090
  else {
9006
9091
  hsl.a -= amount.value / 100;
9007
9092
  }
9008
- hsl.a = clamp$1(hsl.a);
9093
+ hsl.a = clamp(hsl.a);
9009
9094
  return hsla(color, hsl);
9010
9095
  },
9011
9096
  fade: function (color, amount) {
9012
9097
  var hsl = toHSL(color);
9013
9098
  hsl.a = amount.value / 100;
9014
- hsl.a = clamp$1(hsl.a);
9099
+ hsl.a = clamp(hsl.a);
9015
9100
  return hsla(color, hsl);
9016
9101
  },
9017
9102
  spin: function (color, amount) {
@@ -9064,7 +9149,7 @@
9064
9149
  threshold = 0.43;
9065
9150
  }
9066
9151
  else {
9067
- threshold = number(threshold);
9152
+ threshold = number$1(threshold);
9068
9153
  }
9069
9154
  if (color.luma() < threshold) {
9070
9155
  return light;
@@ -9203,9 +9288,9 @@
9203
9288
  return 1 - Math.abs(cb + cs - 1);
9204
9289
  }
9205
9290
  };
9206
- for (var f in colorBlendModeFunctions) {
9207
- if (colorBlendModeFunctions.hasOwnProperty(f)) {
9208
- colorBlend[f] = colorBlend.bind(null, colorBlendModeFunctions[f]);
9291
+ for (var f$1 in colorBlendModeFunctions) {
9292
+ if (colorBlendModeFunctions.hasOwnProperty(f$1)) {
9293
+ colorBlend[f$1] = colorBlend.bind(null, colorBlendModeFunctions[f$1]);
9209
9294
  }
9210
9295
  }
9211
9296
 
@@ -9254,7 +9339,7 @@
9254
9339
  }
9255
9340
  var fileSync = fileManager.loadFileSync(filePath, currentDirectory, context, environment);
9256
9341
  if (!fileSync.contents) {
9257
- logger.warn("Skipped data-uri embedding of " + filePath + " because file not found");
9342
+ logger$1.warn("Skipped data-uri embedding of " + filePath + " because file not found");
9258
9343
  return fallback(this, filePathNode || mimetypeNode);
9259
9344
  }
9260
9345
  var buf = fileSync.contents;
@@ -9425,9 +9510,9 @@
9425
9510
  asin: 'rad',
9426
9511
  acos: 'rad'
9427
9512
  };
9428
- for (var f$1 in mathFunctions) {
9429
- if (mathFunctions.hasOwnProperty(f$1)) {
9430
- mathFunctions[f$1] = MathHelper.bind(null, Math[f$1], mathFunctions[f$1]);
9513
+ for (var f in mathFunctions) {
9514
+ if (mathFunctions.hasOwnProperty(f)) {
9515
+ mathFunctions[f] = MathHelper.bind(null, Math[f], mathFunctions[f]);
9431
9516
  }
9432
9517
  }
9433
9518
  mathFunctions.round = function (n, f) {
@@ -9485,7 +9570,7 @@
9485
9570
  args = order.map(function (a) { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');
9486
9571
  return new Anonymous((isMin ? 'min' : 'max') + "(" + args + ")");
9487
9572
  };
9488
- var number$1 = {
9573
+ var number = {
9489
9574
  min: function () {
9490
9575
  var args = [];
9491
9576
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -9685,7 +9770,8 @@
9685
9770
  isunit: isunit,
9686
9771
  unit: function (val, unit) {
9687
9772
  if (!(val instanceof Dimension)) {
9688
- throw { type: 'Argument', message: "the first argument to unit must be a number" + (val instanceof Operation ? '. Have you forgotten parenthesis?' : '') };
9773
+ throw { type: 'Argument',
9774
+ message: "the first argument to unit must be a number" + (val instanceof Operation ? '. Have you forgotten parenthesis?' : '') };
9689
9775
  }
9690
9776
  if (unit) {
9691
9777
  if (unit instanceof Keyword) {
@@ -9715,7 +9801,7 @@
9715
9801
  functionRegistry.addMultiple(dataUri(environment));
9716
9802
  functionRegistry.addMultiple(list);
9717
9803
  functionRegistry.addMultiple(mathFunctions);
9718
- functionRegistry.addMultiple(number$1);
9804
+ functionRegistry.addMultiple(number);
9719
9805
  functionRegistry.addMultiple(string);
9720
9806
  functionRegistry.addMultiple(svg());
9721
9807
  functionRegistry.addMultiple(types);
@@ -10183,7 +10269,7 @@
10183
10269
  try {
10184
10270
  var compress = Boolean(options.compress);
10185
10271
  if (compress) {
10186
- logger.warn('The compress option has been deprecated. ' +
10272
+ logger$1.warn('The compress option has been deprecated. ' +
10187
10273
  'We recommend you use a dedicated css minifier, for instance see less-plugin-clean-css.');
10188
10274
  }
10189
10275
  var toCSSOptions = {
@@ -10264,7 +10350,7 @@
10264
10350
  var importedEqualsRoot = fullPath === importManager.rootFilename;
10265
10351
  if (importOptions.optional && e) {
10266
10352
  callback(null, { rules: [] }, false, null);
10267
- logger.info("The file " + fullPath + " was skipped because it was not found and the import was marked optional.");
10353
+ logger$1.info("The file " + fullPath + " was skipped because it was not found and the import was marked optional.");
10268
10354
  }
10269
10355
  else {
10270
10356
  // Inline imports aren't cached here.
@@ -10510,7 +10596,7 @@
10510
10596
  return render;
10511
10597
  }
10512
10598
 
10513
- var version = "4.1.0";
10599
+ var version = "4.1.3";
10514
10600
 
10515
10601
  function parseNodeVersion(version) {
10516
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
@@ -10563,7 +10649,7 @@
10563
10649
  transformTree: transformTree,
10564
10650
  utils: utils,
10565
10651
  PluginManager: PluginManagerFactory,
10566
- logger: logger
10652
+ logger: logger$1
10567
10653
  };
10568
10654
  // Create a public API
10569
10655
  var ctor = function (t) {
@@ -10601,8 +10687,8 @@
10601
10687
  }
10602
10688
 
10603
10689
  /* global window, XMLHttpRequest */
10604
- var options;
10605
- var logger$1;
10690
+ var options$1;
10691
+ var logger;
10606
10692
  var fileCache = {};
10607
10693
  // TODOS - move log somewhere. pathDiff and doing something similar in node. use pathDiff in the other browser file for the initial load
10608
10694
  var FileManager = function () { };
@@ -10618,11 +10704,11 @@
10618
10704
  },
10619
10705
  doXHR: function (url, type, callback, errback) {
10620
10706
  var xhr = new XMLHttpRequest();
10621
- var async = options.isFileProtocol ? options.fileAsync : true;
10707
+ var async = options$1.isFileProtocol ? options$1.fileAsync : true;
10622
10708
  if (typeof xhr.overrideMimeType === 'function') {
10623
10709
  xhr.overrideMimeType('text/css');
10624
10710
  }
10625
- logger$1.debug("XHR: Getting '" + url + "'");
10711
+ logger.debug("XHR: Getting '" + url + "'");
10626
10712
  xhr.open('GET', url, async);
10627
10713
  xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5');
10628
10714
  xhr.send(null);
@@ -10634,7 +10720,7 @@
10634
10720
  errback(xhr.status, url);
10635
10721
  }
10636
10722
  }
10637
- if (options.isFileProtocol && !options.fileAsync) {
10723
+ if (options$1.isFileProtocol && !options$1.fileAsync) {
10638
10724
  if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 300)) {
10639
10725
  callback(xhr.responseText);
10640
10726
  }
@@ -10694,8 +10780,8 @@
10694
10780
  }
10695
10781
  });
10696
10782
  var FM = (function (opts, log) {
10697
- options = opts;
10698
- logger$1 = log;
10783
+ options$1 = opts;
10784
+ logger = log;
10699
10785
  return FileManager;
10700
10786
  });
10701
10787
 
@@ -11220,20 +11306,20 @@
11220
11306
  * used in the browser distributed version of less
11221
11307
  * to kick-start less using the browser api
11222
11308
  */
11223
- var options$1 = defaultOptions();
11309
+ var options = defaultOptions();
11224
11310
  if (window.less) {
11225
11311
  for (var key in window.less) {
11226
11312
  if (window.less.hasOwnProperty(key)) {
11227
- options$1[key] = window.less[key];
11313
+ options[key] = window.less[key];
11228
11314
  }
11229
11315
  }
11230
11316
  }
11231
- addDefaultOptions(window, options$1);
11232
- options$1.plugins = options$1.plugins || [];
11317
+ addDefaultOptions(window, options);
11318
+ options.plugins = options.plugins || [];
11233
11319
  if (window.LESS_PLUGINS) {
11234
- options$1.plugins = options$1.plugins.concat(window.LESS_PLUGINS);
11320
+ options.plugins = options.plugins.concat(window.LESS_PLUGINS);
11235
11321
  }
11236
- var less = root(window, options$1);
11322
+ var less = root(window, options);
11237
11323
  window.less = less;
11238
11324
  var css;
11239
11325
  var head;
@@ -11243,16 +11329,16 @@
11243
11329
  if (data.filename) {
11244
11330
  console.warn(data);
11245
11331
  }
11246
- if (!options$1.async) {
11332
+ if (!options.async) {
11247
11333
  head.removeChild(style);
11248
11334
  }
11249
11335
  }
11250
- if (options$1.onReady) {
11336
+ if (options.onReady) {
11251
11337
  if (/!watch/.test(window.location.hash)) {
11252
11338
  less.watch();
11253
11339
  }
11254
11340
  // Simulate synchronous stylesheet loading by hiding page rendering
11255
- if (!options$1.async) {
11341
+ if (!options.async) {
11256
11342
  css = 'body { display: none !important }';
11257
11343
  head = document.head || document.getElementsByTagName('head')[0];
11258
11344
  style = document.createElement('style');