less 4.6.5 → 4.6.7

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' ||
@@ -1920,7 +1926,11 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
1920
1926
  }
1921
1927
  if (closed) {
1922
1928
  if (p && !e) {
1923
- 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);
1924
1934
  e = p;
1925
1935
  } else if (p && e) {
1926
1936
  nodes.push(new (tree.Paren)(new (tree.Declaration)(p, e, null, null, parserInput.i + currentIndex, fileInfo, true)));
@@ -1929,7 +1939,11 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
1929
1939
  }
1930
1940
  spacing = false;
1931
1941
  } else if (e) {
1932
- 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);
1933
1947
  spacing = false;
1934
1948
  } else {
1935
1949
  error('badly formed media feature definition');
@@ -1942,7 +1956,14 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
1942
1956
 
1943
1957
  parserInput.forget();
1944
1958
  if (nodes.length > 0) {
1945
- 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;
1946
1967
  }
1947
1968
  },
1948
1969
 
@@ -2283,10 +2304,10 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
2283
2304
  parserInput.save();
2284
2305
 
2285
2306
  // hsl or rgb or lch operand
2286
- const match = parserInput.$re(/^[lchrgbs]\s+/);
2307
+ const match = parserInput.$re(/^([lchrgbs])(?=\s|[,/*)]|$)/);
2287
2308
  if (match) {
2288
2309
  parserInput.forget();
2289
- return new tree.Keyword(match[0]);
2310
+ return new tree.Keyword(match[1]);
2290
2311
  }
2291
2312
 
2292
2313
  parserInput.restore();
@@ -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.5",
3
+ "version": "4.6.7",
4
4
  "description": "Leaner CSS",
5
5
  "homepage": "http://lesscss.org",
6
6
  "author": {