less 4.2.1 → 4.2.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.
package/dist/less.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Less - Leaner CSS v4.2.1
2
+ * Less - Leaner CSS v4.2.2
3
3
  * http://lesscss.org
4
4
  *
5
- * Copyright (c) 2009-2024, Alexis Sellier <self@cloudhead.net>
5
+ * Copyright (c) 2009-2025, Alexis Sellier <self@cloudhead.net>
6
6
  * Licensed under the Apache-2.0 License.
7
7
  *
8
8
  * @license Apache-2.0
@@ -3238,6 +3238,34 @@
3238
3238
  queryInParens: true
3239
3239
  };
3240
3240
 
3241
+ var Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike, visibilityInfo) {
3242
+ this.value = value;
3243
+ this._index = index;
3244
+ this._fileInfo = currentFileInfo;
3245
+ this.mapLines = mapLines;
3246
+ this.rulesetLike = (typeof rulesetLike === 'undefined') ? false : rulesetLike;
3247
+ this.allowRoot = true;
3248
+ this.copyVisibilityInfo(visibilityInfo);
3249
+ };
3250
+ Anonymous.prototype = Object.assign(new Node(), {
3251
+ type: 'Anonymous',
3252
+ eval: function () {
3253
+ return new Anonymous(this.value, this._index, this._fileInfo, this.mapLines, this.rulesetLike, this.visibilityInfo());
3254
+ },
3255
+ compare: function (other) {
3256
+ return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined;
3257
+ },
3258
+ isRulesetLike: function () {
3259
+ return this.rulesetLike;
3260
+ },
3261
+ genCSS: function (context, output) {
3262
+ this.nodeVisible = Boolean(this.value);
3263
+ if (this.nodeVisible) {
3264
+ output.add(this.value, this._fileInfo, this._index, this.mapLines);
3265
+ }
3266
+ }
3267
+ });
3268
+
3241
3269
  //
3242
3270
  // less.js - parser
3243
3271
  //
@@ -4402,9 +4430,26 @@
4402
4430
  if (!e) {
4403
4431
  parserInput.save();
4404
4432
  if (parserInput.$char('(')) {
4405
- if ((v = this.selector(false)) && parserInput.$char(')')) {
4406
- e = new (tree.Paren)(v);
4407
- parserInput.forget();
4433
+ if ((v = this.selector(false))) {
4434
+ var selectors = [];
4435
+ while (parserInput.$char(',')) {
4436
+ selectors.push(v);
4437
+ selectors.push(new Anonymous(','));
4438
+ v = this.selector(false);
4439
+ }
4440
+ selectors.push(v);
4441
+ if (parserInput.$char(')')) {
4442
+ if (selectors.length > 1) {
4443
+ e = new (tree.Paren)(new Selector(selectors));
4444
+ }
4445
+ else {
4446
+ e = new (tree.Paren)(v);
4447
+ }
4448
+ parserInput.forget();
4449
+ }
4450
+ else {
4451
+ parserInput.restore('Missing closing \')\'');
4452
+ }
4408
4453
  }
4409
4454
  else {
4410
4455
  parserInput.restore('Missing closing \')\'');
@@ -4495,6 +4540,9 @@
4495
4540
  error('Extend can only be used at the end of selector');
4496
4541
  }
4497
4542
  c = parserInput.currentChar();
4543
+ if (Array.isArray(e)) {
4544
+ e.forEach(function (ele) { return elements.push(ele); });
4545
+ }
4498
4546
  if (elements) {
4499
4547
  elements.push(e);
4500
4548
  }
@@ -4669,7 +4717,12 @@
4669
4717
  merge = !isVariable && name.length > 1 && name.pop().value;
4670
4718
  // Custom property values get permissive parsing
4671
4719
  if (name[0].value && name[0].value.slice(0, 2) === '--') {
4672
- value = this.permissiveValue(/[;}]/);
4720
+ if (parserInput.$char(';')) {
4721
+ value = new Anonymous('');
4722
+ }
4723
+ else {
4724
+ value = this.permissiveValue(/[;}]/);
4725
+ }
4673
4726
  }
4674
4727
  // Try to store values as anonymous
4675
4728
  // If we need the value later we'll re-parse it in ruleset.parseValue
@@ -4793,7 +4846,9 @@
4793
4846
  }
4794
4847
  // Treat like quoted values, but replace vars like unquoted expressions
4795
4848
  var quote = new tree.Quoted('\'', item, true, index, fileInfo);
4796
- quote.variableRegex = /@([\w-]+)/g;
4849
+ if (!item.startsWith('@{')) {
4850
+ quote.variableRegex = /@([\w-]+)/g;
4851
+ }
4797
4852
  quote.propRegex = /\$([\w-]+)/g;
4798
4853
  result.push(quote);
4799
4854
  }
@@ -5443,7 +5498,7 @@
5443
5498
  var index = parserInput.i;
5444
5499
  do {
5445
5500
  e = this.comment();
5446
- if (e) {
5501
+ if (e && !e.isLineComment) {
5447
5502
  entities.push(e);
5448
5503
  continue;
5449
5504
  }
@@ -5704,34 +5759,6 @@
5704
5759
  Keyword.True = new Keyword('true');
5705
5760
  Keyword.False = new Keyword('false');
5706
5761
 
5707
- var Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike, visibilityInfo) {
5708
- this.value = value;
5709
- this._index = index;
5710
- this._fileInfo = currentFileInfo;
5711
- this.mapLines = mapLines;
5712
- this.rulesetLike = (typeof rulesetLike === 'undefined') ? false : rulesetLike;
5713
- this.allowRoot = true;
5714
- this.copyVisibilityInfo(visibilityInfo);
5715
- };
5716
- Anonymous.prototype = Object.assign(new Node(), {
5717
- type: 'Anonymous',
5718
- eval: function () {
5719
- return new Anonymous(this.value, this._index, this._fileInfo, this.mapLines, this.rulesetLike, this.visibilityInfo());
5720
- },
5721
- compare: function (other) {
5722
- return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined;
5723
- },
5724
- isRulesetLike: function () {
5725
- return this.rulesetLike;
5726
- },
5727
- genCSS: function (context, output) {
5728
- this.nodeVisible = Boolean(this.value);
5729
- if (this.nodeVisible) {
5730
- output.add(this.value, this._fileInfo, this._index, this.mapLines);
5731
- }
5732
- }
5733
- });
5734
-
5735
5762
  var MATH$1 = Math$1;
5736
5763
  function evalName(context, name) {
5737
5764
  var value = '';
@@ -7583,6 +7610,10 @@
7583
7610
  var path = context.mediaPath.concat([this]);
7584
7611
  // Extract the media-query conditions separated with `,` (OR).
7585
7612
  for (i = 0; i < path.length; i++) {
7613
+ if (path[i].type !== this.type) {
7614
+ context.mediaBlocks.splice(i, 1);
7615
+ return this;
7616
+ }
7586
7617
  value = path[i].features instanceof Value ?
7587
7618
  path[i].features.value : path[i].features;
7588
7619
  path[i] = Array.isArray(value) ? value : [value];
@@ -7978,6 +8009,7 @@
7978
8009
  this.op2 = op2 ? op2.trim() : null;
7979
8010
  this.rvalue = r;
7980
8011
  this._index = i;
8012
+ this.mvalues = [];
7981
8013
  };
7982
8014
  QueryInParens.prototype = Object.assign(new Node(), {
7983
8015
  type: 'QueryInParens',
@@ -7990,7 +8022,32 @@
7990
8022
  },
7991
8023
  eval: function (context) {
7992
8024
  this.lvalue = this.lvalue.eval(context);
7993
- this.mvalue = this.mvalue.eval(context);
8025
+ var variableDeclaration;
8026
+ var rule;
8027
+ for (var i_1 = 0; (rule = context.frames[i_1]); i_1++) {
8028
+ if (rule.type === 'Ruleset') {
8029
+ variableDeclaration = rule.rules.find(function (r) {
8030
+ if ((r instanceof Declaration) && r.variable) {
8031
+ return true;
8032
+ }
8033
+ return false;
8034
+ });
8035
+ if (variableDeclaration) {
8036
+ break;
8037
+ }
8038
+ }
8039
+ }
8040
+ if (!this.mvalueCopy) {
8041
+ this.mvalueCopy = copy(this.mvalue);
8042
+ }
8043
+ if (variableDeclaration) {
8044
+ this.mvalue = this.mvalueCopy;
8045
+ this.mvalue = this.mvalue.eval(context);
8046
+ this.mvalues.push(this.mvalue);
8047
+ }
8048
+ else {
8049
+ this.mvalue = this.mvalue.eval(context);
8050
+ }
7994
8051
  if (this.rvalue) {
7995
8052
  this.rvalue = this.rvalue.eval(context);
7996
8053
  }
@@ -7999,6 +8056,9 @@
7999
8056
  genCSS: function (context, output) {
8000
8057
  this.lvalue.genCSS(context, output);
8001
8058
  output.add(' ' + this.op + ' ');
8059
+ if (this.mvalues.length > 0) {
8060
+ this.mvalue = this.mvalues.shift();
8061
+ }
8002
8062
  this.mvalue.genCSS(context, output);
8003
8063
  if (this.rvalue) {
8004
8064
  output.add(' ' + this.op2 + ' ');
@@ -10792,7 +10852,7 @@
10792
10852
  return render;
10793
10853
  }
10794
10854
 
10795
- var version = "4.2.1";
10855
+ var version = "4.2.2";
10796
10856
 
10797
10857
  function parseNodeVersion(version) {
10798
10858
  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