less 4.4.0 → 4.4.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,5 +1,5 @@
1
1
  /**
2
- * Less - Leaner CSS v4.4.0
2
+ * Less - Leaner CSS v4.4.2
3
3
  * http://lesscss.org
4
4
  *
5
5
  * Copyright (c) 2009-2025, Alexis Sellier <self@cloudhead.net>
@@ -908,7 +908,11 @@
908
908
  output.add(')');
909
909
  },
910
910
  eval: function (context) {
911
- return new Paren(this.value.eval(context));
911
+ var paren = new Paren(this.value.eval(context));
912
+ if (this.noSpacing) {
913
+ paren.noSpacing = true;
914
+ }
915
+ return paren;
912
916
  }
913
917
  });
914
918
 
@@ -5010,8 +5014,14 @@
5010
5014
  var e;
5011
5015
  var p;
5012
5016
  var rangeP;
5017
+ var spacing = false;
5013
5018
  parserInput.save();
5014
5019
  do {
5020
+ parserInput.save();
5021
+ if (parserInput.$re(/^[0-9a-z-]*\s+\(/)) {
5022
+ spacing = true;
5023
+ }
5024
+ parserInput.restore();
5015
5025
  e = entities.declarationCall.bind(this)() || entities.keyword() || entities.variable() || entities.mixinLookup();
5016
5026
  if (e) {
5017
5027
  nodes.push(e);
@@ -5039,9 +5049,14 @@
5039
5049
  }
5040
5050
  else if (p && e) {
5041
5051
  nodes.push(new (tree.Paren)(new (tree.Declaration)(p, e, null, null, parserInput.i + currentIndex, fileInfo, true)));
5052
+ if (!spacing) {
5053
+ nodes[nodes.length - 1].noSpacing = true;
5054
+ }
5055
+ spacing = false;
5042
5056
  }
5043
5057
  else if (e) {
5044
5058
  nodes.push(new (tree.Paren)(e));
5059
+ spacing = false;
5045
5060
  }
5046
5061
  else {
5047
5062
  error('badly formed media feature definition');
@@ -5068,6 +5083,9 @@
5068
5083
  if (!parserInput.$char(',')) {
5069
5084
  break;
5070
5085
  }
5086
+ else if (!features[features.length - 1].noSpacing) {
5087
+ features[features.length - 1].noSpacing = false;
5088
+ }
5071
5089
  }
5072
5090
  else {
5073
5091
  e = entities.variable() || entities.mixinLookup();
@@ -5076,6 +5094,9 @@
5076
5094
  if (!parserInput.$char(',')) {
5077
5095
  break;
5078
5096
  }
5097
+ else if (!features[features.length - 1].noSpacing) {
5098
+ features[features.length - 1].noSpacing = false;
5099
+ }
5079
5100
  }
5080
5101
  }
5081
5102
  } while (e);
@@ -5163,6 +5184,48 @@
5163
5184
  return null;
5164
5185
  }
5165
5186
  },
5187
+ atruleUnknown: function (value, name, hasBlock) {
5188
+ value = this.permissiveValue(/^[{;]/);
5189
+ hasBlock = (parserInput.currentChar() === '{');
5190
+ if (!value) {
5191
+ if (!hasBlock && parserInput.currentChar() !== ';') {
5192
+ error(''.concat(name, ' rule is missing block or ending semi-colon'));
5193
+ }
5194
+ }
5195
+ else if (!value.value) {
5196
+ value = null;
5197
+ }
5198
+ return [value, hasBlock];
5199
+ },
5200
+ atruleBlock: function (rules, value, isRooted, isKeywordList) {
5201
+ rules = this.blockRuleset();
5202
+ parserInput.save();
5203
+ if (!rules && !isRooted) {
5204
+ value = this.entity();
5205
+ rules = this.blockRuleset();
5206
+ }
5207
+ if (!rules && !isRooted) {
5208
+ parserInput.restore();
5209
+ var e = [];
5210
+ value = this.entity();
5211
+ while (parserInput.$char(',')) {
5212
+ e.push(value);
5213
+ value = this.entity();
5214
+ }
5215
+ if (value && e.length > 0) {
5216
+ e.push(value);
5217
+ value = e;
5218
+ isKeywordList = true;
5219
+ }
5220
+ else {
5221
+ rules = this.blockRuleset();
5222
+ }
5223
+ }
5224
+ else {
5225
+ parserInput.forget();
5226
+ }
5227
+ return [rules, value, isKeywordList];
5228
+ },
5166
5229
  //
5167
5230
  // A CSS AtRule
5168
5231
  //
@@ -5238,43 +5301,27 @@
5238
5301
  }
5239
5302
  }
5240
5303
  else if (hasUnknown) {
5241
- value = this.permissiveValue(/^[{;]/);
5242
- hasBlock = (parserInput.currentChar() === '{');
5243
- if (!value) {
5244
- if (!hasBlock && parserInput.currentChar() !== ';') {
5245
- error("".concat(name, " rule is missing block or ending semi-colon"));
5246
- }
5247
- }
5248
- else if (!value.value) {
5249
- value = null;
5250
- }
5304
+ var unknownPackage = this.atruleUnknown(value, name, hasBlock);
5305
+ value = unknownPackage[0];
5306
+ hasBlock = unknownPackage[1];
5251
5307
  }
5252
5308
  if (hasBlock) {
5253
- rules = this.blockRuleset();
5254
- parserInput.save();
5255
- if (!rules && !isRooted) {
5256
- value = this.entity();
5257
- rules = this.blockRuleset();
5258
- }
5259
- if (!rules && !isRooted) {
5309
+ var blockPackage = this.atruleBlock(rules, value, isRooted, isKeywordList);
5310
+ rules = blockPackage[0];
5311
+ value = blockPackage[1];
5312
+ isKeywordList = blockPackage[2];
5313
+ if (!rules && !hasUnknown) {
5260
5314
  parserInput.restore();
5261
- var e = [];
5262
- value = this.entity();
5263
- while (parserInput.$char(',')) {
5264
- e.push(value);
5265
- value = this.entity();
5315
+ name = parserInput.$re(/^@[a-z-]+/);
5316
+ var unknownPackage = this.atruleUnknown(value, name, hasBlock);
5317
+ value = unknownPackage[0];
5318
+ hasBlock = unknownPackage[1];
5319
+ if (hasBlock) {
5320
+ blockPackage = this.atruleBlock(rules, value, isRooted, isKeywordList);
5321
+ rules = blockPackage[0];
5322
+ value = blockPackage[1];
5323
+ isKeywordList = blockPackage[2];
5266
5324
  }
5267
- if (value && e.length > 0) {
5268
- e.push(value);
5269
- value = e;
5270
- isKeywordList = true;
5271
- }
5272
- else {
5273
- rules = this.blockRuleset();
5274
- }
5275
- }
5276
- else {
5277
- parserInput.forget();
5278
5325
  }
5279
5326
  }
5280
5327
  if (rules || isKeywordList || (!hasBlock && value && parserInput.$char(';'))) {
@@ -7119,7 +7166,26 @@
7119
7166
  this.rules = visitor.visitArray(this.rules);
7120
7167
  }
7121
7168
  },
7169
+ evalFunction: function () {
7170
+ if (!this.features || !Array.isArray(this.features.value) || this.features.value.length < 1) {
7171
+ return;
7172
+ }
7173
+ var exprValues = this.features.value;
7174
+ var expr, paren;
7175
+ for (var index = 0; index < exprValues.length; ++index) {
7176
+ expr = exprValues[index];
7177
+ if (expr.type === 'Keyword' && index + 1 < exprValues.length && (expr.noSpacing || expr.noSpacing == null)) {
7178
+ paren = exprValues[index + 1];
7179
+ if (paren.type === 'Paren' && paren.noSpacing) {
7180
+ exprValues[index] = new Expression([expr, paren]);
7181
+ exprValues.splice(index + 1, 1);
7182
+ exprValues[index].noSpacing = true;
7183
+ }
7184
+ }
7185
+ }
7186
+ },
7122
7187
  evalTop: function (context) {
7188
+ this.evalFunction();
7123
7189
  var result = this;
7124
7190
  // Render all dependent Media blocks.
7125
7191
  if (context.mediaBlocks.length > 1) {
@@ -7134,6 +7200,7 @@
7134
7200
  return result;
7135
7201
  },
7136
7202
  evalNested: function (context) {
7203
+ this.evalFunction();
7137
7204
  var i;
7138
7205
  var value;
7139
7206
  var path = context.mediaPath.concat([this]);
@@ -11128,7 +11195,7 @@
11128
11195
  return render;
11129
11196
  }
11130
11197
 
11131
- var version = "4.4.0";
11198
+ var version = "4.4.2";
11132
11199
 
11133
11200
  function parseNodeVersion(version) {
11134
11201
  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