less 4.3.0 → 4.4.1

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.
@@ -1730,8 +1730,14 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
1730
1730
  var e;
1731
1731
  var p;
1732
1732
  var rangeP;
1733
+ var spacing = false;
1733
1734
  parserInput.save();
1734
1735
  do {
1736
+ parserInput.save();
1737
+ if (parserInput.$re(/^[0-9a-z-]*\s+\(/)) {
1738
+ spacing = true;
1739
+ }
1740
+ parserInput.restore();
1735
1741
  e = entities.declarationCall.bind(this)() || entities.keyword() || entities.variable() || entities.mixinLookup();
1736
1742
  if (e) {
1737
1743
  nodes.push(e);
@@ -1759,9 +1765,14 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
1759
1765
  }
1760
1766
  else if (p && e) {
1761
1767
  nodes.push(new (tree_1.default.Paren)(new (tree_1.default.Declaration)(p, e, null, null, parserInput.i + currentIndex, fileInfo, true)));
1768
+ if (!spacing) {
1769
+ nodes[nodes.length - 1].noSpacing = true;
1770
+ }
1771
+ spacing = false;
1762
1772
  }
1763
1773
  else if (e) {
1764
1774
  nodes.push(new (tree_1.default.Paren)(e));
1775
+ spacing = false;
1765
1776
  }
1766
1777
  else {
1767
1778
  error('badly formed media feature definition');
@@ -1883,6 +1894,48 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
1883
1894
  return null;
1884
1895
  }
1885
1896
  },
1897
+ atruleUnknown: function (value, name, hasBlock) {
1898
+ value = this.permissiveValue(/^[{;]/);
1899
+ hasBlock = (parserInput.currentChar() === '{');
1900
+ if (!value) {
1901
+ if (!hasBlock && parserInput.currentChar() !== ';') {
1902
+ error(''.concat(name, ' rule is missing block or ending semi-colon'));
1903
+ }
1904
+ }
1905
+ else if (!value.value) {
1906
+ value = null;
1907
+ }
1908
+ return [value, hasBlock];
1909
+ },
1910
+ atruleBlock: function (rules, value, isRooted, isKeywordList) {
1911
+ rules = this.blockRuleset();
1912
+ parserInput.save();
1913
+ if (!rules && !isRooted) {
1914
+ value = this.entity();
1915
+ rules = this.blockRuleset();
1916
+ }
1917
+ if (!rules && !isRooted) {
1918
+ parserInput.restore();
1919
+ var e = [];
1920
+ value = this.entity();
1921
+ while (parserInput.$char(',')) {
1922
+ e.push(value);
1923
+ value = this.entity();
1924
+ }
1925
+ if (value && e.length > 0) {
1926
+ e.push(value);
1927
+ value = e;
1928
+ isKeywordList = true;
1929
+ }
1930
+ else {
1931
+ rules = this.blockRuleset();
1932
+ }
1933
+ }
1934
+ else {
1935
+ parserInput.forget();
1936
+ }
1937
+ return [rules, value, isKeywordList];
1938
+ },
1886
1939
  //
1887
1940
  // A CSS AtRule
1888
1941
  //
@@ -1899,6 +1952,7 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
1899
1952
  var hasUnknown;
1900
1953
  var hasBlock = true;
1901
1954
  var isRooted = true;
1955
+ var isKeywordList = false;
1902
1956
  if (parserInput.currentChar() !== '@') {
1903
1957
  return;
1904
1958
  }
@@ -1936,6 +1990,9 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
1936
1990
  case '@starting-style':
1937
1991
  isRooted = false;
1938
1992
  break;
1993
+ case '@layer':
1994
+ isRooted = false;
1995
+ break;
1939
1996
  default:
1940
1997
  hasUnknown = true;
1941
1998
  break;
@@ -1954,21 +2011,30 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
1954
2011
  }
1955
2012
  }
1956
2013
  else if (hasUnknown) {
1957
- value = this.permissiveValue(/^[{;]/);
1958
- hasBlock = (parserInput.currentChar() === '{');
1959
- if (!value) {
1960
- if (!hasBlock && parserInput.currentChar() !== ';') {
1961
- error("".concat(name, " rule is missing block or ending semi-colon"));
1962
- }
1963
- }
1964
- else if (!value.value) {
1965
- value = null;
1966
- }
2014
+ var unknownPackage = this.atruleUnknown(value, name, hasBlock);
2015
+ value = unknownPackage[0];
2016
+ hasBlock = unknownPackage[1];
1967
2017
  }
1968
2018
  if (hasBlock) {
1969
- rules = this.blockRuleset();
2019
+ var blockPackage = this.atruleBlock(rules, value, isRooted, isKeywordList);
2020
+ rules = blockPackage[0];
2021
+ value = blockPackage[1];
2022
+ isKeywordList = blockPackage[2];
2023
+ if (!rules && !hasUnknown) {
2024
+ parserInput.restore();
2025
+ name = parserInput.$re(/^@[a-z-]+/);
2026
+ var unknownPackage = this.atruleUnknown(value, name, hasBlock);
2027
+ value = unknownPackage[0];
2028
+ hasBlock = unknownPackage[1];
2029
+ if (hasBlock) {
2030
+ blockPackage = this.atruleBlock(rules, value, isRooted, isKeywordList);
2031
+ rules = blockPackage[0];
2032
+ value = blockPackage[1];
2033
+ isKeywordList = blockPackage[2];
2034
+ }
2035
+ }
1970
2036
  }
1971
- if (rules || (!hasBlock && value && parserInput.$char(';'))) {
2037
+ if (rules || isKeywordList || (!hasBlock && value && parserInput.$char(';'))) {
1972
2038
  parserInput.forget();
1973
2039
  return new (tree_1.default.AtRule)(name, value, rules, index + currentIndex, fileInfo, context.dumpLineNumbers ? getDebugInfo(index) : null, isRooted);
1974
2040
  }
@@ -2021,6 +2087,15 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
2021
2087
  }
2022
2088
  parserInput.restore();
2023
2089
  },
2090
+ colorOperand: function () {
2091
+ parserInput.save();
2092
+ // hsl or rgb or lch operand
2093
+ var match = parserInput.$re(/^[lchrgbs]\s+/);
2094
+ if (match) {
2095
+ return new tree_1.default.Keyword(match[0]);
2096
+ }
2097
+ parserInput.restore();
2098
+ },
2024
2099
  multiplication: function () {
2025
2100
  var m;
2026
2101
  var a;
@@ -2282,7 +2357,7 @@ var Parser = function Parser(context, imports, fileInfo, currentIndex) {
2282
2357
  entities.color() || entities.variable() ||
2283
2358
  entities.property() || entities.call() ||
2284
2359
  entities.quoted(true) || entities.colorKeyword() ||
2285
- entities.mixinLookup();
2360
+ this.colorOperand() || entities.mixinLookup();
2286
2361
  if (negate) {
2287
2362
  o.parensInOp = true;
2288
2363
  o = new (tree_1.default.Negative)(o);