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.
@@ -1875,15 +1875,21 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
1875
1875
  let p;
1876
1876
  let rangeP;
1877
1877
  let spacing = false;
1878
+ const cssKeyword = () => {
1879
+ 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])*/);
1880
+ if (k) {
1881
+ return tree.Color.fromKeyword(k) || new(tree.Keyword)(k);
1882
+ }
1883
+ };
1878
1884
  parserInput.save();
1879
1885
  do {
1880
1886
  parserInput.save();
1881
- if (parserInput.$re(/^[0-9a-z-]*\s+\(/)) {
1887
+ 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+\(/)) {
1882
1888
  spacing = true;
1883
1889
  }
1884
1890
  parserInput.restore();
1885
1891
 
1886
- e = entities.declarationCall.bind(this)() || entities.keyword() || entities.variable() || entities.mixinLookup()
1892
+ e = entities.declarationCall.bind(this)() || cssKeyword() || entities.keyword() || entities.variable() || entities.mixinLookup()
1887
1893
  if (e) {
1888
1894
  nodes.push(e);
1889
1895
  if (e.type === 'Variable' ||
@@ -1891,6 +1897,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
1891
1897
  spacing = true;
1892
1898
  }
1893
1899
  } else if (parserInput.$char('(')) {
1900
+ let closed = false;
1894
1901
  p = this.property();
1895
1902
  parserInput.save();
1896
1903
  if (!p && syntaxOptions.queryInParens && parserInput.$re(/^[0-9a-z-]*\s*([<>]=|<=|>=|[<>]|=)/)) {
@@ -1904,11 +1911,26 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
1904
1911
  }
1905
1912
  } else {
1906
1913
  parserInput.restore();
1914
+ parserInput.save();
1907
1915
  e = this.value();
1916
+ if (e && parserInput.$char(')')) {
1917
+ closed = true;
1918
+ parserInput.forget();
1919
+ } else {
1920
+ parserInput.restore();
1921
+ e = this.mediaFeature(syntaxOptions);
1922
+ }
1923
+ }
1924
+ if (!closed && parserInput.$char(')')) {
1925
+ closed = true;
1908
1926
  }
1909
- if (parserInput.$char(')')) {
1927
+ if (closed) {
1910
1928
  if (p && !e) {
1911
- nodes.push(new (tree.Paren)(new (tree.QueryInParens)(p.op, p.lvalue, p.rvalue, rangeP ? rangeP.op : null, rangeP ? rangeP.rvalue : null, p._index)));
1929
+ const paren = new (tree.Paren)(new (tree.QueryInParens)(p.op, p.lvalue, p.rvalue, rangeP ? rangeP.op : null, rangeP ? rangeP.rvalue : null, p._index));
1930
+ if (!spacing) {
1931
+ paren.noSpacing = true;
1932
+ }
1933
+ nodes.push(paren);
1912
1934
  e = p;
1913
1935
  } else if (p && e) {
1914
1936
  nodes.push(new (tree.Paren)(new (tree.Declaration)(p, e, null, null, parserInput.i + currentIndex, fileInfo, true)));
@@ -1917,7 +1939,11 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
1917
1939
  }
1918
1940
  spacing = false;
1919
1941
  } else if (e) {
1920
- nodes.push(new(tree.Paren)(e));
1942
+ const paren = new(tree.Paren)(e);
1943
+ if (!spacing) {
1944
+ paren.noSpacing = true;
1945
+ }
1946
+ nodes.push(paren);
1921
1947
  spacing = false;
1922
1948
  } else {
1923
1949
  error('badly formed media feature definition');
@@ -1930,7 +1956,14 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
1930
1956
 
1931
1957
  parserInput.forget();
1932
1958
  if (nodes.length > 0) {
1933
- return new(tree.Expression)(nodes);
1959
+ const expression = new(tree.Expression)(nodes);
1960
+ if (nodes.length === 2
1961
+ && (nodes[0].type === 'Keyword' || nodes[0].type === 'Variable')
1962
+ && nodes[1].type === 'Paren'
1963
+ && nodes[1].noSpacing) {
1964
+ expression.noSpacing = true;
1965
+ }
1966
+ return expression;
1934
1967
  }
1935
1968
  },
1936
1969
 
@@ -2271,10 +2304,10 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
2271
2304
  parserInput.save();
2272
2305
 
2273
2306
  // hsl or rgb or lch operand
2274
- const match = parserInput.$re(/^[lchrgbs]\s+/);
2307
+ const match = parserInput.$re(/^([lchrgbs])(?=\s|[,/*)]|$)/);
2275
2308
  if (match) {
2276
2309
  parserInput.forget();
2277
- return new tree.Keyword(match[0]);
2310
+ return new tree.Keyword(match[1]);
2278
2311
  }
2279
2312
 
2280
2313
  parserInput.restore();
@@ -2426,8 +2459,18 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
2426
2459
  const result = this.parenthesisCondition(needsParens);
2427
2460
  if (result) {
2428
2461
  result.negate = !result.negate;
2462
+ return result;
2463
+ }
2464
+
2465
+ // Allow simple bare values (keyword/variable) without parens,
2466
+ // e.g., `not false` or `not @var`.
2467
+ // Complex conditions (comparisons, function calls) require parentheses.
2468
+ const entities = this.entities;
2469
+ const index = parserInput.i;
2470
+ const a = entities.keyword() || entities.variable() || entities.quoted() || entities.mixinLookup();
2471
+ if (a) {
2472
+ return new(tree.Condition)('=', a, new(tree.Keyword)('true'), index + currentIndex, true);
2429
2473
  }
2430
- return result;
2431
2474
  }
2432
2475
  },
2433
2476
  parenthesisCondition: function (needsParens) {
@@ -59,7 +59,9 @@ function asMediaQuery(ctx) {
59
59
  */
60
60
  function debugInfo(context, ctx, lineSeparator) {
61
61
  let result = '';
62
- if (context.dumpLineNumbers && !context.compress) {
62
+ // Some nodes never receive a debugInfo during parsing (e.g. the implicit
63
+ // ruleset of a nested @supports/@document), so there is no line to emit.
64
+ if (context.dumpLineNumbers && !context.compress && ctx.debugInfo) {
63
65
  switch (context.dumpLineNumbers) {
64
66
  case 'comments':
65
67
  result = asComment(ctx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "less",
3
- "version": "4.6.4",
3
+ "version": "4.6.6",
4
4
  "description": "Leaner CSS",
5
5
  "homepage": "http://lesscss.org",
6
6
  "author": {
@@ -29,13 +29,14 @@
29
29
  "main": "./dist/less-node.cjs",
30
30
  "exports": {
31
31
  ".": {
32
- "browser": "./dist/less.js",
32
+ "browser": "./dist/less.cjs",
33
33
  "import": "./lib/less-node/index.js",
34
34
  "require": "./dist/less-node.cjs",
35
35
  "default": "./lib/less-node/index.js"
36
36
  },
37
37
  "./lib/*": "./lib/*",
38
38
  "./dist/less-node.cjs": "./dist/less-node.cjs",
39
+ "./dist/less.cjs": "./dist/less.cjs",
39
40
  "./dist/less.js": "./dist/less.js",
40
41
  "./dist/less.min.js": "./dist/less.min.js"
41
42
  },
@@ -70,7 +71,7 @@
70
71
  "errno": "^0.1.1",
71
72
  "graceful-fs": "^4.1.2",
72
73
  "image-size": "~0.5.0",
73
- "make-dir": "^2.1.0",
74
+ "make-dir": "^5.1.0",
74
75
  "mime": "^1.4.1",
75
76
  "needle": "^3.1.0",
76
77
  "source-map": "~0.6.0"