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.
@@ -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>
@@ -3045,7 +3045,9 @@ function asMediaQuery(ctx) {
3045
3045
  */
3046
3046
  function debugInfo(context, ctx, lineSeparator) {
3047
3047
  let result = '';
3048
- if (context.dumpLineNumbers && !context.compress) {
3048
+ // Some nodes never receive a debugInfo during parsing (e.g. the implicit
3049
+ // ruleset of a nested @supports/@document), so there is no line to emit.
3050
+ if (context.dumpLineNumbers && !context.compress && ctx.debugInfo) {
3049
3051
  switch (context.dumpLineNumbers) {
3050
3052
  case 'comments':
3051
3053
  result = asComment(ctx);
@@ -6384,15 +6386,21 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
6384
6386
  let p;
6385
6387
  let rangeP;
6386
6388
  let spacing = false;
6389
+ const cssKeyword = () => {
6390
+ 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])*/);
6391
+ if (k) {
6392
+ return tree.Color.fromKeyword(k) || new(tree.Keyword)(k);
6393
+ }
6394
+ };
6387
6395
  parserInput.save();
6388
6396
  do {
6389
6397
  parserInput.save();
6390
- if (parserInput.$re(/^[0-9a-z-]*\s+\(/)) {
6398
+ 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+\(/)) {
6391
6399
  spacing = true;
6392
6400
  }
6393
6401
  parserInput.restore();
6394
6402
 
6395
- e = entities.declarationCall.bind(this)() || entities.keyword() || entities.variable() || entities.mixinLookup();
6403
+ e = entities.declarationCall.bind(this)() || cssKeyword() || entities.keyword() || entities.variable() || entities.mixinLookup();
6396
6404
  if (e) {
6397
6405
  nodes.push(e);
6398
6406
  if (e.type === 'Variable' ||
@@ -6400,6 +6408,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
6400
6408
  spacing = true;
6401
6409
  }
6402
6410
  } else if (parserInput.$char('(')) {
6411
+ let closed = false;
6403
6412
  p = this.property();
6404
6413
  parserInput.save();
6405
6414
  if (!p && syntaxOptions.queryInParens && parserInput.$re(/^[0-9a-z-]*\s*([<>]=|<=|>=|[<>]|=)/)) {
@@ -6413,11 +6422,26 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
6413
6422
  }
6414
6423
  } else {
6415
6424
  parserInput.restore();
6425
+ parserInput.save();
6416
6426
  e = this.value();
6427
+ if (e && parserInput.$char(')')) {
6428
+ closed = true;
6429
+ parserInput.forget();
6430
+ } else {
6431
+ parserInput.restore();
6432
+ e = this.mediaFeature(syntaxOptions);
6433
+ }
6434
+ }
6435
+ if (!closed && parserInput.$char(')')) {
6436
+ closed = true;
6417
6437
  }
6418
- if (parserInput.$char(')')) {
6438
+ if (closed) {
6419
6439
  if (p && !e) {
6420
- nodes.push(new (tree.Paren)(new (tree.QueryInParens)(p.op, p.lvalue, p.rvalue, rangeP ? rangeP.op : null, rangeP ? rangeP.rvalue : null, p._index)));
6440
+ const paren = new (tree.Paren)(new (tree.QueryInParens)(p.op, p.lvalue, p.rvalue, rangeP ? rangeP.op : null, rangeP ? rangeP.rvalue : null, p._index));
6441
+ if (!spacing) {
6442
+ paren.noSpacing = true;
6443
+ }
6444
+ nodes.push(paren);
6421
6445
  e = p;
6422
6446
  } else if (p && e) {
6423
6447
  nodes.push(new (tree.Paren)(new (tree.Declaration)(p, e, null, null, parserInput.i + currentIndex, fileInfo, true)));
@@ -6426,7 +6450,11 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
6426
6450
  }
6427
6451
  spacing = false;
6428
6452
  } else if (e) {
6429
- nodes.push(new(tree.Paren)(e));
6453
+ const paren = new(tree.Paren)(e);
6454
+ if (!spacing) {
6455
+ paren.noSpacing = true;
6456
+ }
6457
+ nodes.push(paren);
6430
6458
  spacing = false;
6431
6459
  } else {
6432
6460
  error('badly formed media feature definition');
@@ -6439,7 +6467,14 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
6439
6467
 
6440
6468
  parserInput.forget();
6441
6469
  if (nodes.length > 0) {
6442
- return new(tree.Expression)(nodes);
6470
+ const expression = new(tree.Expression)(nodes);
6471
+ if (nodes.length === 2
6472
+ && (nodes[0].type === 'Keyword' || nodes[0].type === 'Variable')
6473
+ && nodes[1].type === 'Paren'
6474
+ && nodes[1].noSpacing) {
6475
+ expression.noSpacing = true;
6476
+ }
6477
+ return expression;
6443
6478
  }
6444
6479
  },
6445
6480
 
@@ -6780,10 +6815,10 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
6780
6815
  parserInput.save();
6781
6816
 
6782
6817
  // hsl or rgb or lch operand
6783
- const match = parserInput.$re(/^[lchrgbs]\s+/);
6818
+ const match = parserInput.$re(/^([lchrgbs])(?=\s|[,/*)]|$)/);
6784
6819
  if (match) {
6785
6820
  parserInput.forget();
6786
- return new tree.Keyword(match[0]);
6821
+ return new tree.Keyword(match[1]);
6787
6822
  }
6788
6823
 
6789
6824
  parserInput.restore();
@@ -6935,8 +6970,18 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
6935
6970
  const result = this.parenthesisCondition(needsParens);
6936
6971
  if (result) {
6937
6972
  result.negate = !result.negate;
6973
+ return result;
6974
+ }
6975
+
6976
+ // Allow simple bare values (keyword/variable) without parens,
6977
+ // e.g., `not false` or `not @var`.
6978
+ // Complex conditions (comparisons, function calls) require parentheses.
6979
+ const entities = this.entities;
6980
+ const index = parserInput.i;
6981
+ const a = entities.keyword() || entities.variable() || entities.quoted() || entities.mixinLookup();
6982
+ if (a) {
6983
+ return new(tree.Condition)('=', a, new(tree.Keyword)('true'), index + currentIndex, true);
6938
6984
  }
6939
- return result;
6940
6985
  }
6941
6986
  },
6942
6987
  parenthesisCondition: function (needsParens) {
@@ -14045,7 +14090,7 @@ var imageSize = environment => {
14045
14090
  };
14046
14091
 
14047
14092
  createRequire();
14048
- const version = "4.6.4";
14093
+ const version = "4.6.6";
14049
14094
 
14050
14095
  const less = createFromEnvironment(environment, [new FileManager(), new UrlFileManager()], version);
14051
14096