less 4.6.4 → 4.6.6

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.6.4
2
+ * Less - Leaner CSS v4.6.6
3
3
  * http://lesscss.org
4
4
  *
5
5
  * Copyright (c) 2009-2026, Alexis Sellier <self@cloudhead.net>
@@ -2878,7 +2878,9 @@
2878
2878
  */
2879
2879
  function debugInfo(context, ctx, lineSeparator) {
2880
2880
  let result = '';
2881
- if (context.dumpLineNumbers && !context.compress) {
2881
+ // Some nodes never receive a debugInfo during parsing (e.g. the implicit
2882
+ // ruleset of a nested @supports/@document), so there is no line to emit.
2883
+ if (context.dumpLineNumbers && !context.compress && ctx.debugInfo) {
2882
2884
  switch (context.dumpLineNumbers) {
2883
2885
  case 'comments':
2884
2886
  result = asComment(ctx);
@@ -6217,15 +6219,21 @@
6217
6219
  let p;
6218
6220
  let rangeP;
6219
6221
  let spacing = false;
6222
+ const cssKeyword = () => {
6223
+ const k = parserInput.$re(/^(?:--|-?(?:[_a-zA-Z0-9]|[^\0-\x7F]|\\[0-9a-fA-F]{1,6}\s?|\\[^\n\r\f0-9a-fA-F]))(?:[-_a-zA-Z0-9]|[^\0-\x7F]|\\[0-9a-fA-F]{1,6}\s?|\\[^\n\r\f0-9a-fA-F])*/);
6224
+ if (k) {
6225
+ return tree.Color.fromKeyword(k) || new(tree.Keyword)(k);
6226
+ }
6227
+ };
6220
6228
  parserInput.save();
6221
6229
  do {
6222
6230
  parserInput.save();
6223
- if (parserInput.$re(/^[0-9a-z-]*\s+\(/)) {
6231
+ if (parserInput.$re(/^(?:--|-?(?:[_a-zA-Z0-9]|[^\0-\x7F]|\\[0-9a-fA-F]{1,6}\s?|\\[^\n\r\f0-9a-fA-F]))(?:[-_a-zA-Z0-9]|[^\0-\x7F]|\\[0-9a-fA-F]{1,6}\s?|\\[^\n\r\f0-9a-fA-F])*\s+\(/)) {
6224
6232
  spacing = true;
6225
6233
  }
6226
6234
  parserInput.restore();
6227
6235
 
6228
- e = entities.declarationCall.bind(this)() || entities.keyword() || entities.variable() || entities.mixinLookup();
6236
+ e = entities.declarationCall.bind(this)() || cssKeyword() || entities.keyword() || entities.variable() || entities.mixinLookup();
6229
6237
  if (e) {
6230
6238
  nodes.push(e);
6231
6239
  if (e.type === 'Variable' ||
@@ -6233,6 +6241,7 @@
6233
6241
  spacing = true;
6234
6242
  }
6235
6243
  } else if (parserInput.$char('(')) {
6244
+ let closed = false;
6236
6245
  p = this.property();
6237
6246
  parserInput.save();
6238
6247
  if (!p && syntaxOptions.queryInParens && parserInput.$re(/^[0-9a-z-]*\s*([<>]=|<=|>=|[<>]|=)/)) {
@@ -6246,11 +6255,26 @@
6246
6255
  }
6247
6256
  } else {
6248
6257
  parserInput.restore();
6258
+ parserInput.save();
6249
6259
  e = this.value();
6260
+ if (e && parserInput.$char(')')) {
6261
+ closed = true;
6262
+ parserInput.forget();
6263
+ } else {
6264
+ parserInput.restore();
6265
+ e = this.mediaFeature(syntaxOptions);
6266
+ }
6267
+ }
6268
+ if (!closed && parserInput.$char(')')) {
6269
+ closed = true;
6250
6270
  }
6251
- if (parserInput.$char(')')) {
6271
+ if (closed) {
6252
6272
  if (p && !e) {
6253
- nodes.push(new (tree.Paren)(new (tree.QueryInParens)(p.op, p.lvalue, p.rvalue, rangeP ? rangeP.op : null, rangeP ? rangeP.rvalue : null, p._index)));
6273
+ const paren = new (tree.Paren)(new (tree.QueryInParens)(p.op, p.lvalue, p.rvalue, rangeP ? rangeP.op : null, rangeP ? rangeP.rvalue : null, p._index));
6274
+ if (!spacing) {
6275
+ paren.noSpacing = true;
6276
+ }
6277
+ nodes.push(paren);
6254
6278
  e = p;
6255
6279
  } else if (p && e) {
6256
6280
  nodes.push(new (tree.Paren)(new (tree.Declaration)(p, e, null, null, parserInput.i + currentIndex, fileInfo, true)));
@@ -6259,7 +6283,11 @@
6259
6283
  }
6260
6284
  spacing = false;
6261
6285
  } else if (e) {
6262
- nodes.push(new(tree.Paren)(e));
6286
+ const paren = new(tree.Paren)(e);
6287
+ if (!spacing) {
6288
+ paren.noSpacing = true;
6289
+ }
6290
+ nodes.push(paren);
6263
6291
  spacing = false;
6264
6292
  } else {
6265
6293
  error('badly formed media feature definition');
@@ -6272,7 +6300,14 @@
6272
6300
 
6273
6301
  parserInput.forget();
6274
6302
  if (nodes.length > 0) {
6275
- return new(tree.Expression)(nodes);
6303
+ const expression = new(tree.Expression)(nodes);
6304
+ if (nodes.length === 2
6305
+ && (nodes[0].type === 'Keyword' || nodes[0].type === 'Variable')
6306
+ && nodes[1].type === 'Paren'
6307
+ && nodes[1].noSpacing) {
6308
+ expression.noSpacing = true;
6309
+ }
6310
+ return expression;
6276
6311
  }
6277
6312
  },
6278
6313
 
@@ -6613,10 +6648,10 @@
6613
6648
  parserInput.save();
6614
6649
 
6615
6650
  // hsl or rgb or lch operand
6616
- const match = parserInput.$re(/^[lchrgbs]\s+/);
6651
+ const match = parserInput.$re(/^([lchrgbs])(?=\s|[,/*)]|$)/);
6617
6652
  if (match) {
6618
6653
  parserInput.forget();
6619
- return new tree.Keyword(match[0]);
6654
+ return new tree.Keyword(match[1]);
6620
6655
  }
6621
6656
 
6622
6657
  parserInput.restore();
@@ -6768,8 +6803,18 @@
6768
6803
  const result = this.parenthesisCondition(needsParens);
6769
6804
  if (result) {
6770
6805
  result.negate = !result.negate;
6806
+ return result;
6807
+ }
6808
+
6809
+ // Allow simple bare values (keyword/variable) without parens,
6810
+ // e.g., `not false` or `not @var`.
6811
+ // Complex conditions (comparisons, function calls) require parentheses.
6812
+ const entities = this.entities;
6813
+ const index = parserInput.i;
6814
+ const a = entities.keyword() || entities.variable() || entities.quoted() || entities.mixinLookup();
6815
+ if (a) {
6816
+ return new(tree.Condition)('=', a, new(tree.Keyword)('true'), index + currentIndex, true);
6771
6817
  }
6772
- return result;
6773
6818
  }
6774
6819
  },
6775
6820
  parenthesisCondition: function (needsParens) {
@@ -14130,7 +14175,7 @@
14130
14175
  };
14131
14176
 
14132
14177
  var name = "less";
14133
- var version = "4.6.4";
14178
+ var version = "4.6.6";
14134
14179
  var description = "Leaner CSS";
14135
14180
  var homepage = "http://lesscss.org";
14136
14181
  var author = {
@@ -14159,13 +14204,14 @@
14159
14204
  var main = "./dist/less-node.cjs";
14160
14205
  var exports$1 = {
14161
14206
  ".": {
14162
- browser: "./dist/less.js",
14207
+ browser: "./dist/less.cjs",
14163
14208
  "import": "./lib/less-node/index.js",
14164
14209
  require: "./dist/less-node.cjs",
14165
14210
  "default": "./lib/less-node/index.js"
14166
14211
  },
14167
14212
  "./lib/*": "./lib/*",
14168
14213
  "./dist/less-node.cjs": "./dist/less-node.cjs",
14214
+ "./dist/less.cjs": "./dist/less.cjs",
14169
14215
  "./dist/less.js": "./dist/less.js",
14170
14216
  "./dist/less.min.js": "./dist/less.min.js"
14171
14217
  };
@@ -14200,7 +14246,7 @@
14200
14246
  errno: "^0.1.1",
14201
14247
  "graceful-fs": "^4.1.2",
14202
14248
  "image-size": "~0.5.0",
14203
- "make-dir": "^2.1.0",
14249
+ "make-dir": "^5.1.0",
14204
14250
  mime: "^1.4.1",
14205
14251
  needle: "^3.1.0",
14206
14252
  "source-map": "~0.6.0"