vscode-css-languageservice 5.4.2 → 6.1.0

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.
Files changed (83) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/SECURITY.md +41 -0
  3. package/lib/esm/beautify/beautify-css.js +11 -4
  4. package/lib/esm/cssLanguageService.d.ts +2 -1
  5. package/lib/esm/cssLanguageService.js +15 -17
  6. package/lib/esm/cssLanguageTypes.js +2 -2
  7. package/lib/esm/data/webCustomData.js +356 -232
  8. package/lib/esm/languageFacts/builtinData.js +15 -15
  9. package/lib/esm/languageFacts/colors.js +66 -69
  10. package/lib/esm/languageFacts/dataManager.js +38 -42
  11. package/lib/esm/languageFacts/dataProvider.js +17 -23
  12. package/lib/esm/languageFacts/entry.js +22 -23
  13. package/lib/esm/parser/cssErrors.js +5 -7
  14. package/lib/esm/parser/cssNodes.js +869 -1377
  15. package/lib/esm/parser/cssParser.js +419 -376
  16. package/lib/esm/parser/cssScanner.js +168 -175
  17. package/lib/esm/parser/cssSymbolScope.js +107 -137
  18. package/lib/esm/parser/lessParser.js +177 -202
  19. package/lib/esm/parser/lessScanner.js +22 -43
  20. package/lib/esm/parser/scssErrors.js +5 -7
  21. package/lib/esm/parser/scssParser.js +196 -208
  22. package/lib/esm/parser/scssScanner.js +33 -54
  23. package/lib/esm/services/cssCodeActions.js +36 -40
  24. package/lib/esm/services/cssCompletion.js +300 -395
  25. package/lib/esm/services/cssFolding.js +32 -35
  26. package/lib/esm/services/cssFormatter.js +22 -22
  27. package/lib/esm/services/cssHover.js +30 -33
  28. package/lib/esm/services/cssNavigation.js +260 -289
  29. package/lib/esm/services/cssSelectionRange.js +6 -6
  30. package/lib/esm/services/cssValidation.js +13 -16
  31. package/lib/esm/services/lessCompletion.js +351 -370
  32. package/lib/esm/services/lint.js +161 -175
  33. package/lib/esm/services/lintRules.js +20 -27
  34. package/lib/esm/services/lintUtil.js +19 -28
  35. package/lib/esm/services/pathCompletion.js +84 -158
  36. package/lib/esm/services/scssCompletion.js +283 -307
  37. package/lib/esm/services/scssNavigation.js +65 -137
  38. package/lib/esm/services/selectorPrinting.js +131 -175
  39. package/lib/esm/utils/arrays.js +6 -12
  40. package/lib/esm/utils/objects.js +1 -1
  41. package/lib/esm/utils/resources.js +3 -16
  42. package/lib/esm/utils/strings.js +10 -12
  43. package/lib/umd/beautify/beautify-css.js +11 -4
  44. package/lib/umd/cssLanguageService.d.ts +2 -1
  45. package/lib/umd/cssLanguageService.js +34 -32
  46. package/lib/umd/cssLanguageTypes.js +4 -3
  47. package/lib/umd/data/webCustomData.js +355 -231
  48. package/lib/umd/languageFacts/colors.js +65 -68
  49. package/lib/umd/languageFacts/dataManager.js +41 -44
  50. package/lib/umd/languageFacts/dataProvider.js +17 -22
  51. package/lib/umd/languageFacts/entry.js +22 -23
  52. package/lib/umd/languageFacts/facts.js +5 -1
  53. package/lib/umd/parser/cssErrors.js +5 -6
  54. package/lib/umd/parser/cssNodes.js +870 -1307
  55. package/lib/umd/parser/cssParser.js +424 -380
  56. package/lib/umd/parser/cssScanner.js +168 -173
  57. package/lib/umd/parser/cssSymbolScope.js +109 -134
  58. package/lib/umd/parser/lessParser.js +182 -206
  59. package/lib/umd/parser/lessScanner.js +22 -42
  60. package/lib/umd/parser/scssErrors.js +5 -6
  61. package/lib/umd/parser/scssParser.js +202 -213
  62. package/lib/umd/parser/scssScanner.js +25 -45
  63. package/lib/umd/services/cssCodeActions.js +41 -44
  64. package/lib/umd/services/cssCompletion.js +308 -402
  65. package/lib/umd/services/cssFolding.js +35 -38
  66. package/lib/umd/services/cssFormatter.js +25 -25
  67. package/lib/umd/services/cssHover.js +36 -38
  68. package/lib/umd/services/cssNavigation.js +267 -295
  69. package/lib/umd/services/cssSelectionRange.js +8 -8
  70. package/lib/umd/services/cssValidation.js +17 -19
  71. package/lib/umd/services/lessCompletion.js +354 -372
  72. package/lib/umd/services/lint.js +167 -180
  73. package/lib/umd/services/lintRules.js +20 -24
  74. package/lib/umd/services/lintUtil.js +20 -28
  75. package/lib/umd/services/pathCompletion.js +87 -160
  76. package/lib/umd/services/scssCompletion.js +287 -310
  77. package/lib/umd/services/scssNavigation.js +69 -140
  78. package/lib/umd/services/selectorPrinting.js +134 -174
  79. package/lib/umd/utils/arrays.js +6 -12
  80. package/lib/umd/utils/objects.js +1 -1
  81. package/lib/umd/utils/resources.js +4 -17
  82. package/lib/umd/utils/strings.js +10 -12
  83. package/package.json +16 -15
@@ -1,12 +1,3 @@
1
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
- if (ar || !(i in from)) {
4
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
- ar[i] = from[i];
6
- }
7
- }
8
- return to.concat(ar || Array.prototype.slice.call(from));
9
- };
10
1
  (function (factory) {
11
2
  if (typeof module === "object" && typeof module.exports === "object") {
12
3
  var v = factory(require, exports);
@@ -23,90 +14,84 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
23
14
  'use strict';
24
15
  Object.defineProperty(exports, "__esModule", { value: true });
25
16
  exports.Parser = void 0;
26
- var cssScanner_1 = require("./cssScanner");
27
- var nodes = require("./cssNodes");
28
- var cssErrors_1 = require("./cssErrors");
29
- var languageFacts = require("../languageFacts/facts");
30
- var objects_1 = require("../utils/objects");
17
+ const cssScanner_1 = require("./cssScanner");
18
+ const nodes = require("./cssNodes");
19
+ const cssErrors_1 = require("./cssErrors");
20
+ const languageFacts = require("../languageFacts/facts");
21
+ const objects_1 = require("../utils/objects");
31
22
  /// <summary>
32
23
  /// A parser for the css core specification. See for reference:
33
24
  /// https://www.w3.org/TR/CSS21/grammar.html
34
25
  /// http://www.w3.org/TR/CSS21/syndata.html#tokenization
35
26
  /// </summary>
36
- var Parser = /** @class */ (function () {
37
- function Parser(scnr) {
38
- if (scnr === void 0) { scnr = new cssScanner_1.Scanner(); }
27
+ class Parser {
28
+ constructor(scnr = new cssScanner_1.Scanner()) {
39
29
  this.keyframeRegex = /^@(\-(webkit|ms|moz|o)\-)?keyframes$/i;
40
30
  this.scanner = scnr;
41
31
  this.token = { type: cssScanner_1.TokenType.EOF, offset: -1, len: 0, text: '' };
42
32
  this.prevToken = undefined;
43
33
  }
44
- Parser.prototype.peekIdent = function (text) {
34
+ peekIdent(text) {
45
35
  return cssScanner_1.TokenType.Ident === this.token.type && text.length === this.token.text.length && text === this.token.text.toLowerCase();
46
- };
47
- Parser.prototype.peekKeyword = function (text) {
36
+ }
37
+ peekKeyword(text) {
48
38
  return cssScanner_1.TokenType.AtKeyword === this.token.type && text.length === this.token.text.length && text === this.token.text.toLowerCase();
49
- };
50
- Parser.prototype.peekDelim = function (text) {
39
+ }
40
+ peekDelim(text) {
51
41
  return cssScanner_1.TokenType.Delim === this.token.type && text === this.token.text;
52
- };
53
- Parser.prototype.peek = function (type) {
42
+ }
43
+ peek(type) {
54
44
  return type === this.token.type;
55
- };
56
- Parser.prototype.peekOne = function () {
57
- var types = [];
58
- for (var _i = 0; _i < arguments.length; _i++) {
59
- types[_i] = arguments[_i];
60
- }
45
+ }
46
+ peekOne(...types) {
61
47
  return types.indexOf(this.token.type) !== -1;
62
- };
63
- Parser.prototype.peekRegExp = function (type, regEx) {
48
+ }
49
+ peekRegExp(type, regEx) {
64
50
  if (type !== this.token.type) {
65
51
  return false;
66
52
  }
67
53
  return regEx.test(this.token.text);
68
- };
69
- Parser.prototype.hasWhitespace = function () {
54
+ }
55
+ hasWhitespace() {
70
56
  return !!this.prevToken && (this.prevToken.offset + this.prevToken.len !== this.token.offset);
71
- };
72
- Parser.prototype.consumeToken = function () {
57
+ }
58
+ consumeToken() {
73
59
  this.prevToken = this.token;
74
60
  this.token = this.scanner.scan();
75
- };
76
- Parser.prototype.acceptUnicodeRange = function () {
77
- var token = this.scanner.tryScanUnicode();
61
+ }
62
+ acceptUnicodeRange() {
63
+ const token = this.scanner.tryScanUnicode();
78
64
  if (token) {
79
65
  this.prevToken = token;
80
66
  this.token = this.scanner.scan();
81
67
  return true;
82
68
  }
83
69
  return false;
84
- };
85
- Parser.prototype.mark = function () {
70
+ }
71
+ mark() {
86
72
  return {
87
73
  prev: this.prevToken,
88
74
  curr: this.token,
89
75
  pos: this.scanner.pos()
90
76
  };
91
- };
92
- Parser.prototype.restoreAtMark = function (mark) {
77
+ }
78
+ restoreAtMark(mark) {
93
79
  this.prevToken = mark.prev;
94
80
  this.token = mark.curr;
95
81
  this.scanner.goBackTo(mark.pos);
96
- };
97
- Parser.prototype.try = function (func) {
98
- var pos = this.mark();
99
- var node = func();
82
+ }
83
+ try(func) {
84
+ const pos = this.mark();
85
+ const node = func();
100
86
  if (!node) {
101
87
  this.restoreAtMark(pos);
102
88
  return null;
103
89
  }
104
90
  return node;
105
- };
106
- Parser.prototype.acceptOneKeyword = function (keywords) {
91
+ }
92
+ acceptOneKeyword(keywords) {
107
93
  if (cssScanner_1.TokenType.AtKeyword === this.token.type) {
108
- for (var _i = 0, keywords_1 = keywords; _i < keywords_1.length; _i++) {
109
- var keyword = keywords_1[_i];
94
+ for (const keyword of keywords) {
110
95
  if (keyword.length === this.token.text.length && keyword === this.token.text.toLowerCase()) {
111
96
  this.consumeToken();
112
97
  return true;
@@ -114,51 +99,51 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
114
99
  }
115
100
  }
116
101
  return false;
117
- };
118
- Parser.prototype.accept = function (type) {
102
+ }
103
+ accept(type) {
119
104
  if (type === this.token.type) {
120
105
  this.consumeToken();
121
106
  return true;
122
107
  }
123
108
  return false;
124
- };
125
- Parser.prototype.acceptIdent = function (text) {
109
+ }
110
+ acceptIdent(text) {
126
111
  if (this.peekIdent(text)) {
127
112
  this.consumeToken();
128
113
  return true;
129
114
  }
130
115
  return false;
131
- };
132
- Parser.prototype.acceptKeyword = function (text) {
116
+ }
117
+ acceptKeyword(text) {
133
118
  if (this.peekKeyword(text)) {
134
119
  this.consumeToken();
135
120
  return true;
136
121
  }
137
122
  return false;
138
- };
139
- Parser.prototype.acceptDelim = function (text) {
123
+ }
124
+ acceptDelim(text) {
140
125
  if (this.peekDelim(text)) {
141
126
  this.consumeToken();
142
127
  return true;
143
128
  }
144
129
  return false;
145
- };
146
- Parser.prototype.acceptRegexp = function (regEx) {
130
+ }
131
+ acceptRegexp(regEx) {
147
132
  if (regEx.test(this.token.text)) {
148
133
  this.consumeToken();
149
134
  return true;
150
135
  }
151
136
  return false;
152
- };
153
- Parser.prototype._parseRegexp = function (regEx) {
154
- var node = this.createNode(nodes.NodeType.Identifier);
137
+ }
138
+ _parseRegexp(regEx) {
139
+ let node = this.createNode(nodes.NodeType.Identifier);
155
140
  do { } while (this.acceptRegexp(regEx));
156
141
  return this.finish(node);
157
- };
158
- Parser.prototype.acceptUnquotedString = function () {
159
- var pos = this.scanner.pos();
142
+ }
143
+ acceptUnquotedString() {
144
+ const pos = this.scanner.pos();
160
145
  this.scanner.goBackTo(this.token.offset);
161
- var unquoted = this.scanner.scanUnquotedString();
146
+ const unquoted = this.scanner.scanUnquotedString();
162
147
  if (unquoted) {
163
148
  this.token = unquoted;
164
149
  this.consumeToken();
@@ -166,8 +151,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
166
151
  }
167
152
  this.scanner.goBackTo(pos);
168
153
  return false;
169
- };
170
- Parser.prototype.resync = function (resyncTokens, resyncStopTokens) {
154
+ }
155
+ resync(resyncTokens, resyncStopTokens) {
171
156
  while (true) {
172
157
  if (resyncTokens && resyncTokens.indexOf(this.token.type) !== -1) {
173
158
  this.consumeToken();
@@ -183,14 +168,14 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
183
168
  this.token = this.scanner.scan();
184
169
  }
185
170
  }
186
- };
187
- Parser.prototype.createNode = function (nodeType) {
171
+ }
172
+ createNode(nodeType) {
188
173
  return new nodes.Node(this.token.offset, this.token.len, nodeType);
189
- };
190
- Parser.prototype.create = function (ctor) {
174
+ }
175
+ create(ctor) {
191
176
  return new ctor(this.token.offset, this.token.len);
192
- };
193
- Parser.prototype.finish = function (node, error, resyncTokens, resyncStopTokens) {
177
+ }
178
+ finish(node, error, resyncTokens, resyncStopTokens) {
194
179
  // parseNumeric misuses error for boolean flagging (however the real error mustn't be a false)
195
180
  // + nodelist offsets mustn't be modified, because there is a offset hack in rulesets for smartselection
196
181
  if (!(node instanceof nodes.Nodelist)) {
@@ -200,13 +185,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
200
185
  // set the node end position
201
186
  if (this.prevToken) {
202
187
  // length with more elements belonging together
203
- var prevEnd = this.prevToken.offset + this.prevToken.len;
188
+ const prevEnd = this.prevToken.offset + this.prevToken.len;
204
189
  node.length = prevEnd > node.offset ? prevEnd - node.offset : 0; // offset is taken from current token, end from previous: Use 0 for empty nodes
205
190
  }
206
191
  }
207
192
  return node;
208
- };
209
- Parser.prototype.markError = function (node, error, resyncTokens, resyncStopTokens) {
193
+ }
194
+ markError(node, error, resyncTokens, resyncStopTokens) {
210
195
  if (this.token !== this.lastErrorToken) { // do not report twice on the same token
211
196
  node.addIssue(new nodes.Marker(node, error, nodes.Level.Error, undefined, this.token.offset, this.token.len));
212
197
  this.lastErrorToken = this.token;
@@ -214,43 +199,43 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
214
199
  if (resyncTokens || resyncStopTokens) {
215
200
  this.resync(resyncTokens, resyncStopTokens);
216
201
  }
217
- };
218
- Parser.prototype.parseStylesheet = function (textDocument) {
219
- var versionId = textDocument.version;
220
- var text = textDocument.getText();
221
- var textProvider = function (offset, length) {
202
+ }
203
+ parseStylesheet(textDocument) {
204
+ const versionId = textDocument.version;
205
+ const text = textDocument.getText();
206
+ const textProvider = (offset, length) => {
222
207
  if (textDocument.version !== versionId) {
223
208
  throw new Error('Underlying model has changed, AST is no longer valid');
224
209
  }
225
210
  return text.substr(offset, length);
226
211
  };
227
212
  return this.internalParse(text, this._parseStylesheet, textProvider);
228
- };
229
- Parser.prototype.internalParse = function (input, parseFunc, textProvider) {
213
+ }
214
+ internalParse(input, parseFunc, textProvider) {
230
215
  this.scanner.setSource(input);
231
216
  this.token = this.scanner.scan();
232
- var node = parseFunc.bind(this)();
217
+ const node = parseFunc.bind(this)();
233
218
  if (node) {
234
219
  if (textProvider) {
235
220
  node.textProvider = textProvider;
236
221
  }
237
222
  else {
238
- node.textProvider = function (offset, length) { return input.substr(offset, length); };
223
+ node.textProvider = (offset, length) => { return input.substr(offset, length); };
239
224
  }
240
225
  }
241
226
  return node;
242
- };
243
- Parser.prototype._parseStylesheet = function () {
244
- var node = this.create(nodes.Stylesheet);
227
+ }
228
+ _parseStylesheet() {
229
+ const node = this.create(nodes.Stylesheet);
245
230
  while (node.addChild(this._parseStylesheetStart())) {
246
231
  // Parse statements only valid at the beginning of stylesheets.
247
232
  }
248
- var inRecovery = false;
233
+ let inRecovery = false;
249
234
  do {
250
- var hasMatch = false;
235
+ let hasMatch = false;
251
236
  do {
252
237
  hasMatch = false;
253
- var statement = this._parseStylesheetStatement();
238
+ const statement = this._parseStylesheetStatement();
254
239
  if (statement) {
255
240
  node.addChild(statement);
256
241
  hasMatch = true;
@@ -280,32 +265,31 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
280
265
  this.consumeToken();
281
266
  } while (!this.peek(cssScanner_1.TokenType.EOF));
282
267
  return this.finish(node);
283
- };
284
- Parser.prototype._parseStylesheetStart = function () {
268
+ }
269
+ _parseStylesheetStart() {
285
270
  return this._parseCharset();
286
- };
287
- Parser.prototype._parseStylesheetStatement = function (isNested) {
288
- if (isNested === void 0) { isNested = false; }
271
+ }
272
+ _parseStylesheetStatement(isNested = false) {
289
273
  if (this.peek(cssScanner_1.TokenType.AtKeyword)) {
290
274
  return this._parseStylesheetAtStatement(isNested);
291
275
  }
292
276
  return this._parseRuleset(isNested);
293
- };
294
- Parser.prototype._parseStylesheetAtStatement = function (isNested) {
295
- if (isNested === void 0) { isNested = false; }
277
+ }
278
+ _parseStylesheetAtStatement(isNested = false) {
296
279
  return this._parseImport()
297
280
  || this._parseMedia(isNested)
298
281
  || this._parsePage()
299
282
  || this._parseFontFace()
300
283
  || this._parseKeyframe()
301
284
  || this._parseSupports(isNested)
285
+ || this._parseLayer()
302
286
  || this._parseViewPort()
303
287
  || this._parseNamespace()
304
288
  || this._parseDocument()
305
289
  || this._parseUnknownAtRule();
306
- };
307
- Parser.prototype._tryParseRuleset = function (isNested) {
308
- var mark = this.mark();
290
+ }
291
+ _tryParseRuleset(isNested) {
292
+ const mark = this.mark();
309
293
  if (this._parseSelector(isNested)) {
310
294
  while (this.accept(cssScanner_1.TokenType.Comma) && this._parseSelector(isNested)) {
311
295
  // loop
@@ -317,11 +301,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
317
301
  }
318
302
  this.restoreAtMark(mark);
319
303
  return null;
320
- };
321
- Parser.prototype._parseRuleset = function (isNested) {
322
- if (isNested === void 0) { isNested = false; }
323
- var node = this.create(nodes.RuleSet);
324
- var selectors = node.getSelectors();
304
+ }
305
+ _parseRuleset(isNested = false) {
306
+ const node = this.create(nodes.RuleSet);
307
+ const selectors = node.getSelectors();
325
308
  if (!selectors.addChild(this._parseSelector(isNested))) {
326
309
  return null;
327
310
  }
@@ -331,18 +314,18 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
331
314
  }
332
315
  }
333
316
  return this._parseBody(node, this._parseRuleSetDeclaration.bind(this));
334
- };
335
- Parser.prototype._parseRuleSetDeclarationAtStatement = function () {
317
+ }
318
+ _parseRuleSetDeclarationAtStatement() {
336
319
  return this._parseUnknownAtRule();
337
- };
338
- Parser.prototype._parseRuleSetDeclaration = function () {
320
+ }
321
+ _parseRuleSetDeclaration() {
339
322
  // https://www.w3.org/TR/css-syntax-3/#consume-a-list-of-declarations
340
323
  if (this.peek(cssScanner_1.TokenType.AtKeyword)) {
341
324
  return this._parseRuleSetDeclarationAtStatement();
342
325
  }
343
326
  return this._parseDeclaration();
344
- };
345
- Parser.prototype._needsSemicolonAfter = function (node) {
327
+ }
328
+ _needsSemicolonAfter(node) {
346
329
  switch (node.type) {
347
330
  case nodes.NodeType.Keyframe:
348
331
  case nodes.NodeType.ViewPort:
@@ -374,13 +357,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
374
357
  return !node.getNestedProperties();
375
358
  }
376
359
  return false;
377
- };
378
- Parser.prototype._parseDeclarations = function (parseDeclaration) {
379
- var node = this.create(nodes.Declarations);
360
+ }
361
+ _parseDeclarations(parseDeclaration) {
362
+ const node = this.create(nodes.Declarations);
380
363
  if (!this.accept(cssScanner_1.TokenType.CurlyL)) {
381
364
  return null;
382
365
  }
383
- var decl = parseDeclaration();
366
+ let decl = parseDeclaration();
384
367
  while (node.addChild(decl)) {
385
368
  if (this.peek(cssScanner_1.TokenType.CurlyR)) {
386
369
  break;
@@ -401,16 +384,16 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
401
384
  return this.finish(node, cssErrors_1.ParseError.RightCurlyExpected, [cssScanner_1.TokenType.CurlyR, cssScanner_1.TokenType.SemiColon]);
402
385
  }
403
386
  return this.finish(node);
404
- };
405
- Parser.prototype._parseBody = function (node, parseDeclaration) {
387
+ }
388
+ _parseBody(node, parseDeclaration) {
406
389
  if (!node.setDeclarations(this._parseDeclarations(parseDeclaration))) {
407
390
  return this.finish(node, cssErrors_1.ParseError.LeftCurlyExpected, [cssScanner_1.TokenType.CurlyR, cssScanner_1.TokenType.SemiColon]);
408
391
  }
409
392
  return this.finish(node);
410
- };
411
- Parser.prototype._parseSelector = function (isNested) {
412
- var node = this.create(nodes.Selector);
413
- var hasContent = false;
393
+ }
394
+ _parseSelector(isNested) {
395
+ const node = this.create(nodes.Selector);
396
+ let hasContent = false;
414
397
  if (isNested) {
415
398
  // nested selectors can start with a combinator
416
399
  hasContent = node.addChild(this._parseCombinator());
@@ -420,13 +403,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
420
403
  node.addChild(this._parseCombinator()); // optional
421
404
  }
422
405
  return hasContent ? this.finish(node) : null;
423
- };
424
- Parser.prototype._parseDeclaration = function (stopTokens) {
425
- var custonProperty = this._tryParseCustomPropertyDeclaration(stopTokens);
406
+ }
407
+ _parseDeclaration(stopTokens) {
408
+ const custonProperty = this._tryParseCustomPropertyDeclaration(stopTokens);
426
409
  if (custonProperty) {
427
410
  return custonProperty;
428
411
  }
429
- var node = this.create(nodes.Declaration);
412
+ const node = this.create(nodes.Declaration);
430
413
  if (!node.setProperty(this._parseProperty())) {
431
414
  return null;
432
415
  }
@@ -444,12 +427,12 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
444
427
  node.semicolonPosition = this.token.offset; // not part of the declaration, but useful information for code assist
445
428
  }
446
429
  return this.finish(node);
447
- };
448
- Parser.prototype._tryParseCustomPropertyDeclaration = function (stopTokens) {
430
+ }
431
+ _tryParseCustomPropertyDeclaration(stopTokens) {
449
432
  if (!this.peekRegExp(cssScanner_1.TokenType.Ident, /^--/)) {
450
433
  return null;
451
434
  }
452
- var node = this.create(nodes.CustomPropertyDeclaration);
435
+ const node = this.create(nodes.CustomPropertyDeclaration);
453
436
  if (!node.setProperty(this._parseProperty())) {
454
437
  return null;
455
438
  }
@@ -459,11 +442,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
459
442
  if (this.prevToken) {
460
443
  node.colonPosition = this.prevToken.offset;
461
444
  }
462
- var mark = this.mark();
445
+ const mark = this.mark();
463
446
  if (this.peek(cssScanner_1.TokenType.CurlyL)) {
464
447
  // try to parse it as nested declaration
465
- var propertySet = this.create(nodes.CustomPropertySet);
466
- var declarations = this._parseDeclarations(this._parseRuleSetDeclaration.bind(this));
448
+ const propertySet = this.create(nodes.CustomPropertySet);
449
+ const declarations = this._parseDeclarations(this._parseRuleSetDeclaration.bind(this));
467
450
  if (propertySet.setDeclarations(declarations) && !declarations.isErroneous(true)) {
468
451
  propertySet.addChild(this._parsePrio());
469
452
  if (this.peek(cssScanner_1.TokenType.SemiColon)) {
@@ -476,10 +459,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
476
459
  this.restoreAtMark(mark);
477
460
  }
478
461
  // try to parse as expression
479
- var expression = this._parseExpr();
462
+ const expression = this._parseExpr();
480
463
  if (expression && !expression.isErroneous(true)) {
481
464
  this._parsePrio();
482
- if (this.peekOne.apply(this, __spreadArray(__spreadArray([], (stopTokens || []), false), [cssScanner_1.TokenType.SemiColon, cssScanner_1.TokenType.EOF], false))) {
465
+ if (this.peekOne(...(stopTokens || []), cssScanner_1.TokenType.SemiColon, cssScanner_1.TokenType.EOF)) {
483
466
  node.setValue(expression);
484
467
  if (this.peek(cssScanner_1.TokenType.SemiColon)) {
485
468
  node.semicolonPosition = this.token.offset; // not part of the declaration, but useful information for code assist
@@ -494,7 +477,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
494
477
  return this.finish(node, cssErrors_1.ParseError.PropertyValueExpected);
495
478
  }
496
479
  return this.finish(node);
497
- };
480
+ }
498
481
  /**
499
482
  * Parse custom property values.
500
483
  *
@@ -506,15 +489,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
506
489
  * terminators like semicolons and !important directives (when not inside
507
490
  * of delimitors).
508
491
  */
509
- Parser.prototype._parseCustomPropertyValue = function (stopTokens) {
510
- var _this = this;
511
- if (stopTokens === void 0) { stopTokens = [cssScanner_1.TokenType.CurlyR]; }
512
- var node = this.create(nodes.Node);
513
- var isTopLevel = function () { return curlyDepth === 0 && parensDepth === 0 && bracketsDepth === 0; };
514
- var onStopToken = function () { return stopTokens.indexOf(_this.token.type) !== -1; };
515
- var curlyDepth = 0;
516
- var parensDepth = 0;
517
- var bracketsDepth = 0;
492
+ _parseCustomPropertyValue(stopTokens = [cssScanner_1.TokenType.CurlyR]) {
493
+ const node = this.create(nodes.Node);
494
+ const isTopLevel = () => curlyDepth === 0 && parensDepth === 0 && bracketsDepth === 0;
495
+ const onStopToken = () => stopTokens.indexOf(this.token.type) !== -1;
496
+ let curlyDepth = 0;
497
+ let parensDepth = 0;
498
+ let bracketsDepth = 0;
518
499
  done: while (true) {
519
500
  switch (this.token.type) {
520
501
  case cssScanner_1.TokenType.SemiColon:
@@ -569,7 +550,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
569
550
  case cssScanner_1.TokenType.EOF:
570
551
  // We shouldn't have reached the end of input, something is
571
552
  // unterminated.
572
- var error = cssErrors_1.ParseError.RightCurlyExpected;
553
+ let error = cssErrors_1.ParseError.RightCurlyExpected;
573
554
  if (bracketsDepth > 0) {
574
555
  error = cssErrors_1.ParseError.RightSquareBracketExpected;
575
556
  }
@@ -581,9 +562,9 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
581
562
  this.consumeToken();
582
563
  }
583
564
  return this.finish(node);
584
- };
585
- Parser.prototype._tryToParseDeclaration = function (stopTokens) {
586
- var mark = this.mark();
565
+ }
566
+ _tryToParseDeclaration(stopTokens) {
567
+ const mark = this.mark();
587
568
  if (this._parseProperty() && this.accept(cssScanner_1.TokenType.Colon)) {
588
569
  // looks like a declaration, go ahead
589
570
  this.restoreAtMark(mark);
@@ -591,10 +572,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
591
572
  }
592
573
  this.restoreAtMark(mark);
593
574
  return null;
594
- };
595
- Parser.prototype._parseProperty = function () {
596
- var node = this.create(nodes.Property);
597
- var mark = this.mark();
575
+ }
576
+ _parseProperty() {
577
+ const node = this.create(nodes.Property);
578
+ const mark = this.mark();
598
579
  if (this.acceptDelim('*') || this.acceptDelim('_')) {
599
580
  // support for IE 5.x, 6 and 7 star hack: see http://en.wikipedia.org/wiki/CSS_filter#Star_hack
600
581
  if (this.hasWhitespace()) {
@@ -606,15 +587,15 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
606
587
  return this.finish(node);
607
588
  }
608
589
  return null;
609
- };
610
- Parser.prototype._parsePropertyIdentifier = function () {
590
+ }
591
+ _parsePropertyIdentifier() {
611
592
  return this._parseIdent();
612
- };
613
- Parser.prototype._parseCharset = function () {
593
+ }
594
+ _parseCharset() {
614
595
  if (!this.peek(cssScanner_1.TokenType.Charset)) {
615
596
  return null;
616
597
  }
617
- var node = this.create(nodes.Node);
598
+ const node = this.create(nodes.Node);
618
599
  this.consumeToken(); // charset
619
600
  if (!this.accept(cssScanner_1.TokenType.String)) {
620
601
  return this.finish(node, cssErrors_1.ParseError.IdentifierExpected);
@@ -623,28 +604,51 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
623
604
  return this.finish(node, cssErrors_1.ParseError.SemiColonExpected);
624
605
  }
625
606
  return this.finish(node);
626
- };
627
- Parser.prototype._parseImport = function () {
607
+ }
608
+ _parseImport() {
609
+ // @import [ <url> | <string> ]
610
+ // [ layer | layer(<layer-name>) ]?
611
+ // <import-condition> ;
612
+ // <import-conditions> = [ supports( [ <supports-condition> | <declaration> ] ) ]?
613
+ // <media-query-list>?
628
614
  if (!this.peekKeyword('@import')) {
629
615
  return null;
630
616
  }
631
- var node = this.create(nodes.Import);
617
+ const node = this.create(nodes.Import);
632
618
  this.consumeToken(); // @import
633
619
  if (!node.addChild(this._parseURILiteral()) && !node.addChild(this._parseStringLiteral())) {
634
620
  return this.finish(node, cssErrors_1.ParseError.URIOrStringExpected);
635
621
  }
622
+ if (this.acceptIdent('layer')) {
623
+ if (this.accept(cssScanner_1.TokenType.ParenthesisL)) {
624
+ if (!node.addChild(this._parseLayerName())) {
625
+ return this.finish(node, cssErrors_1.ParseError.IdentifierExpected, [cssScanner_1.TokenType.SemiColon]);
626
+ }
627
+ if (!this.accept(cssScanner_1.TokenType.ParenthesisR)) {
628
+ return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected, [cssScanner_1.TokenType.ParenthesisR], []);
629
+ }
630
+ }
631
+ }
632
+ if (this.acceptIdent('supports')) {
633
+ if (this.accept(cssScanner_1.TokenType.ParenthesisL)) {
634
+ node.addChild(this._tryToParseDeclaration() || this._parseSupportsCondition());
635
+ if (!this.accept(cssScanner_1.TokenType.ParenthesisR)) {
636
+ return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected, [cssScanner_1.TokenType.ParenthesisR], []);
637
+ }
638
+ }
639
+ }
636
640
  if (!this.peek(cssScanner_1.TokenType.SemiColon) && !this.peek(cssScanner_1.TokenType.EOF)) {
637
641
  node.setMedialist(this._parseMediaQueryList());
638
642
  }
639
643
  return this.finish(node);
640
- };
641
- Parser.prototype._parseNamespace = function () {
644
+ }
645
+ _parseNamespace() {
642
646
  // http://www.w3.org/TR/css3-namespace/
643
647
  // namespace : NAMESPACE_SYM S* [IDENT S*]? [STRING|URI] S* ';' S*
644
648
  if (!this.peekKeyword('@namespace')) {
645
649
  return null;
646
650
  }
647
- var node = this.create(nodes.Namespace);
651
+ const node = this.create(nodes.Namespace);
648
652
  this.consumeToken(); // @namespace
649
653
  if (!node.addChild(this._parseURILiteral())) { // url literal also starts with ident
650
654
  node.addChild(this._parseIdent()); // optional prefix
@@ -656,31 +660,31 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
656
660
  return this.finish(node, cssErrors_1.ParseError.SemiColonExpected);
657
661
  }
658
662
  return this.finish(node);
659
- };
660
- Parser.prototype._parseFontFace = function () {
663
+ }
664
+ _parseFontFace() {
661
665
  if (!this.peekKeyword('@font-face')) {
662
666
  return null;
663
667
  }
664
- var node = this.create(nodes.FontFace);
668
+ const node = this.create(nodes.FontFace);
665
669
  this.consumeToken(); // @font-face
666
670
  return this._parseBody(node, this._parseRuleSetDeclaration.bind(this));
667
- };
668
- Parser.prototype._parseViewPort = function () {
671
+ }
672
+ _parseViewPort() {
669
673
  if (!this.peekKeyword('@-ms-viewport') &&
670
674
  !this.peekKeyword('@-o-viewport') &&
671
675
  !this.peekKeyword('@viewport')) {
672
676
  return null;
673
677
  }
674
- var node = this.create(nodes.ViewPort);
678
+ const node = this.create(nodes.ViewPort);
675
679
  this.consumeToken(); // @-ms-viewport
676
680
  return this._parseBody(node, this._parseRuleSetDeclaration.bind(this));
677
- };
678
- Parser.prototype._parseKeyframe = function () {
681
+ }
682
+ _parseKeyframe() {
679
683
  if (!this.peekRegExp(cssScanner_1.TokenType.AtKeyword, this.keyframeRegex)) {
680
684
  return null;
681
685
  }
682
- var node = this.create(nodes.Keyframe);
683
- var atNode = this.create(nodes.Node);
686
+ const node = this.create(nodes.Keyframe);
687
+ const atNode = this.create(nodes.Node);
684
688
  this.consumeToken(); // atkeyword
685
689
  node.setKeyword(this.finish(atNode));
686
690
  if (atNode.matches('@-ms-keyframes')) { // -ms-keyframes never existed
@@ -690,12 +694,12 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
690
694
  return this.finish(node, cssErrors_1.ParseError.IdentifierExpected, [cssScanner_1.TokenType.CurlyR]);
691
695
  }
692
696
  return this._parseBody(node, this._parseKeyframeSelector.bind(this));
693
- };
694
- Parser.prototype._parseKeyframeIdent = function () {
697
+ }
698
+ _parseKeyframeIdent() {
695
699
  return this._parseIdent([nodes.ReferenceType.Keyframe]);
696
- };
697
- Parser.prototype._parseKeyframeSelector = function () {
698
- var node = this.create(nodes.KeyframeSelector);
700
+ }
701
+ _parseKeyframeSelector() {
702
+ const node = this.create(nodes.KeyframeSelector);
699
703
  if (!node.addChild(this._parseIdent()) && !this.accept(cssScanner_1.TokenType.Percentage)) {
700
704
  return null;
701
705
  }
@@ -705,10 +709,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
705
709
  }
706
710
  }
707
711
  return this._parseBody(node, this._parseRuleSetDeclaration.bind(this));
708
- };
709
- Parser.prototype._tryParseKeyframeSelector = function () {
710
- var node = this.create(nodes.KeyframeSelector);
711
- var pos = this.mark();
712
+ }
713
+ _tryParseKeyframeSelector() {
714
+ const node = this.create(nodes.KeyframeSelector);
715
+ const pos = this.mark();
712
716
  if (!node.addChild(this._parseIdent()) && !this.accept(cssScanner_1.TokenType.Percentage)) {
713
717
  return null;
714
718
  }
@@ -723,20 +727,66 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
723
727
  return null;
724
728
  }
725
729
  return this._parseBody(node, this._parseRuleSetDeclaration.bind(this));
726
- };
727
- Parser.prototype._parseSupports = function (isNested) {
728
- if (isNested === void 0) { isNested = false; }
730
+ }
731
+ _parseLayer() {
732
+ // @layer layer-name {rules}
733
+ // @layer layer-name;
734
+ // @layer layer-name, layer-name, layer-name;
735
+ // @layer {rules}
736
+ if (!this.peekKeyword('@layer')) {
737
+ return null;
738
+ }
739
+ const node = this.create(nodes.Layer);
740
+ this.consumeToken(); // @layer
741
+ const names = this._parseLayerNameList();
742
+ if (names) {
743
+ node.setNames(names);
744
+ }
745
+ if ((!names || names.getChildren().length === 1) && this.peek(cssScanner_1.TokenType.CurlyL)) {
746
+ return this._parseBody(node, this._parseStylesheetStatement.bind(this));
747
+ }
748
+ if (!this.accept(cssScanner_1.TokenType.SemiColon)) {
749
+ return this.finish(node, cssErrors_1.ParseError.SemiColonExpected);
750
+ }
751
+ return this.finish(node);
752
+ }
753
+ _parseLayerNameList() {
754
+ const node = this.createNode(nodes.NodeType.LayerNameList);
755
+ if (!node.addChild(this._parseLayerName())) {
756
+ return null;
757
+ }
758
+ while (this.accept(cssScanner_1.TokenType.Comma)) {
759
+ if (!node.addChild(this._parseLayerName())) {
760
+ return this.finish(node, cssErrors_1.ParseError.IdentifierExpected);
761
+ }
762
+ }
763
+ return this.finish(node);
764
+ }
765
+ _parseLayerName() {
766
+ // <layer-name> = <ident> [ '.' <ident> ]*
767
+ if (!this.peek(cssScanner_1.TokenType.Ident)) {
768
+ return null;
769
+ }
770
+ const node = this.createNode(nodes.NodeType.LayerName);
771
+ node.addChild(this._parseIdent());
772
+ while (!this.hasWhitespace() && this.acceptDelim('.')) {
773
+ if (this.hasWhitespace() || !node.addChild(this._parseIdent())) {
774
+ return this.finish(node, cssErrors_1.ParseError.IdentifierExpected);
775
+ }
776
+ }
777
+ return this.finish(node);
778
+ }
779
+ _parseSupports(isNested = false) {
729
780
  // SUPPORTS_SYM S* supports_condition '{' S* ruleset* '}' S*
730
781
  if (!this.peekKeyword('@supports')) {
731
782
  return null;
732
783
  }
733
- var node = this.create(nodes.Supports);
784
+ const node = this.create(nodes.Supports);
734
785
  this.consumeToken(); // @supports
735
786
  node.addChild(this._parseSupportsCondition());
736
787
  return this._parseBody(node, this._parseSupportsDeclaration.bind(this, isNested));
737
- };
738
- Parser.prototype._parseSupportsDeclaration = function (isNested) {
739
- if (isNested === void 0) { isNested = false; }
788
+ }
789
+ _parseSupportsDeclaration(isNested = false) {
740
790
  if (isNested) {
741
791
  // if nested, the body can contain rulesets, but also declarations
742
792
  return this._tryParseRuleset(true)
@@ -744,8 +794,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
744
794
  || this._parseStylesheetStatement(true);
745
795
  }
746
796
  return this._parseStylesheetStatement(false);
747
- };
748
- Parser.prototype._parseSupportsCondition = function () {
797
+ }
798
+ _parseSupportsCondition() {
749
799
  // supports_condition : supports_negation | supports_conjunction | supports_disjunction | supports_condition_in_parens ;
750
800
  // supports_condition_in_parens: ( '(' S* supports_condition S* ')' ) | supports_declaration_condition | general_enclosed ;
751
801
  // supports_negation: NOT S+ supports_condition_in_parens ;
@@ -753,23 +803,23 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
753
803
  // supports_disjunction: supports_condition_in_parens ( S+ OR S+ supports_condition_in_parens )+;
754
804
  // supports_declaration_condition: '(' S* declaration ')';
755
805
  // general_enclosed: ( FUNCTION | '(' ) ( any | unused )* ')' ;
756
- var node = this.create(nodes.SupportsCondition);
806
+ const node = this.create(nodes.SupportsCondition);
757
807
  if (this.acceptIdent('not')) {
758
808
  node.addChild(this._parseSupportsConditionInParens());
759
809
  }
760
810
  else {
761
811
  node.addChild(this._parseSupportsConditionInParens());
762
812
  if (this.peekRegExp(cssScanner_1.TokenType.Ident, /^(and|or)$/i)) {
763
- var text = this.token.text.toLowerCase();
813
+ const text = this.token.text.toLowerCase();
764
814
  while (this.acceptIdent(text)) {
765
815
  node.addChild(this._parseSupportsConditionInParens());
766
816
  }
767
817
  }
768
818
  }
769
819
  return this.finish(node);
770
- };
771
- Parser.prototype._parseSupportsConditionInParens = function () {
772
- var node = this.create(nodes.SupportsCondition);
820
+ }
821
+ _parseSupportsConditionInParens() {
822
+ const node = this.create(nodes.SupportsCondition);
773
823
  if (this.accept(cssScanner_1.TokenType.ParenthesisL)) {
774
824
  if (this.prevToken) {
775
825
  node.lParent = this.prevToken.offset;
@@ -788,10 +838,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
788
838
  return this.finish(node);
789
839
  }
790
840
  else if (this.peek(cssScanner_1.TokenType.Ident)) {
791
- var pos = this.mark();
841
+ const pos = this.mark();
792
842
  this.consumeToken();
793
843
  if (!this.hasWhitespace() && this.accept(cssScanner_1.TokenType.ParenthesisL)) {
794
- var openParentCount = 1;
844
+ let openParentCount = 1;
795
845
  while (this.token.type !== cssScanner_1.TokenType.EOF && openParentCount !== 0) {
796
846
  if (this.token.type === cssScanner_1.TokenType.ParenthesisL) {
797
847
  openParentCount++;
@@ -808,9 +858,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
808
858
  }
809
859
  }
810
860
  return this.finish(node, cssErrors_1.ParseError.LeftParenthesisExpected, [], [cssScanner_1.TokenType.ParenthesisL]);
811
- };
812
- Parser.prototype._parseMediaDeclaration = function (isNested) {
813
- if (isNested === void 0) { isNested = false; }
861
+ }
862
+ _parseMediaDeclaration(isNested = false) {
814
863
  if (isNested) {
815
864
  // if nested, the body can contain rulesets, but also declarations
816
865
  return this._tryParseRuleset(true)
@@ -818,23 +867,22 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
818
867
  || this._parseStylesheetStatement(true);
819
868
  }
820
869
  return this._parseStylesheetStatement(false);
821
- };
822
- Parser.prototype._parseMedia = function (isNested) {
823
- if (isNested === void 0) { isNested = false; }
870
+ }
871
+ _parseMedia(isNested = false) {
824
872
  // MEDIA_SYM S* media_query_list '{' S* ruleset* '}' S*
825
873
  // media_query_list : S* [media_query [ ',' S* media_query ]* ]?
826
874
  if (!this.peekKeyword('@media')) {
827
875
  return null;
828
876
  }
829
- var node = this.create(nodes.Media);
877
+ const node = this.create(nodes.Media);
830
878
  this.consumeToken(); // @media
831
879
  if (!node.addChild(this._parseMediaQueryList())) {
832
880
  return this.finish(node, cssErrors_1.ParseError.MediaQueryExpected);
833
881
  }
834
882
  return this._parseBody(node, this._parseMediaDeclaration.bind(this, isNested));
835
- };
836
- Parser.prototype._parseMediaQueryList = function () {
837
- var node = this.create(nodes.Medialist);
883
+ }
884
+ _parseMediaQueryList() {
885
+ const node = this.create(nodes.Medialist);
838
886
  if (!node.addChild(this._parseMediaQuery())) {
839
887
  return this.finish(node, cssErrors_1.ParseError.MediaQueryExpected);
840
888
  }
@@ -844,11 +892,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
844
892
  }
845
893
  }
846
894
  return this.finish(node);
847
- };
848
- Parser.prototype._parseMediaQuery = function () {
895
+ }
896
+ _parseMediaQuery() {
849
897
  // <media-query> = <media-condition> | [ not | only ]? <media-type> [ and <media-condition-without-or> ]?
850
- var node = this.create(nodes.MediaQuery);
851
- var pos = this.mark();
898
+ const node = this.create(nodes.MediaQuery);
899
+ const pos = this.mark();
852
900
  this.acceptIdent('not');
853
901
  if (!this.peek(cssScanner_1.TokenType.ParenthesisL)) {
854
902
  if (this.acceptIdent('only')) {
@@ -866,10 +914,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
866
914
  node.addChild(this._parseMediaCondition());
867
915
  }
868
916
  return this.finish(node);
869
- };
870
- Parser.prototype._parseRatio = function () {
871
- var pos = this.mark();
872
- var node = this.create(nodes.RatioValue);
917
+ }
918
+ _parseRatio() {
919
+ const pos = this.mark();
920
+ const node = this.create(nodes.RatioValue);
873
921
  if (!this._parseNumeric()) {
874
922
  return null;
875
923
  }
@@ -881,16 +929,16 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
881
929
  return this.finish(node, cssErrors_1.ParseError.NumberExpected);
882
930
  }
883
931
  return this.finish(node);
884
- };
885
- Parser.prototype._parseMediaCondition = function () {
932
+ }
933
+ _parseMediaCondition() {
886
934
  // <media-condition> = <media-not> | <media-and> | <media-or> | <media-in-parens>
887
935
  // <media-not> = not <media-in-parens>
888
936
  // <media-and> = <media-in-parens> [ and <media-in-parens> ]+
889
937
  // <media-or> = <media-in-parens> [ or <media-in-parens> ]+
890
938
  // <media-in-parens> = ( <media-condition> ) | <media-feature> | <general-enclosed>
891
- var node = this.create(nodes.MediaCondition);
939
+ const node = this.create(nodes.MediaCondition);
892
940
  this.acceptIdent('not');
893
- var parseExpression = true;
941
+ let parseExpression = true;
894
942
  while (parseExpression) {
895
943
  if (!this.accept(cssScanner_1.TokenType.ParenthesisL)) {
896
944
  return this.finish(node, cssErrors_1.ParseError.LeftParenthesisExpected, [], [cssScanner_1.TokenType.CurlyL]);
@@ -909,23 +957,22 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
909
957
  parseExpression = this.acceptIdent('and') || this.acceptIdent('or');
910
958
  }
911
959
  return this.finish(node);
912
- };
913
- Parser.prototype._parseMediaFeature = function () {
914
- var _this = this;
915
- var resyncStopToken = [cssScanner_1.TokenType.ParenthesisR];
916
- var node = this.create(nodes.MediaFeature);
960
+ }
961
+ _parseMediaFeature() {
962
+ const resyncStopToken = [cssScanner_1.TokenType.ParenthesisR];
963
+ const node = this.create(nodes.MediaFeature);
917
964
  // <media-feature> = ( [ <mf-plain> | <mf-boolean> | <mf-range> ] )
918
965
  // <mf-plain> = <mf-name> : <mf-value>
919
966
  // <mf-boolean> = <mf-name>
920
967
  // <mf-range> = <mf-name> [ '<' | '>' ]? '='? <mf-value> | <mf-value> [ '<' | '>' ]? '='? <mf-name> | <mf-value> '<' '='? <mf-name> '<' '='? <mf-value> | <mf-value> '>' '='? <mf-name> '>' '='? <mf-value>
921
- var parseRangeOperator = function () {
922
- if (_this.acceptDelim('<') || _this.acceptDelim('>')) {
923
- if (!_this.hasWhitespace()) {
924
- _this.acceptDelim('=');
968
+ const parseRangeOperator = () => {
969
+ if (this.acceptDelim('<') || this.acceptDelim('>')) {
970
+ if (!this.hasWhitespace()) {
971
+ this.acceptDelim('=');
925
972
  }
926
973
  return true;
927
974
  }
928
- else if (_this.acceptDelim('=')) {
975
+ else if (this.acceptDelim('=')) {
929
976
  return true;
930
977
  }
931
978
  return false;
@@ -967,33 +1014,33 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
967
1014
  return this.finish(node, cssErrors_1.ParseError.IdentifierExpected, [], resyncStopToken);
968
1015
  }
969
1016
  return this.finish(node);
970
- };
971
- Parser.prototype._parseMediaFeatureName = function () {
1017
+ }
1018
+ _parseMediaFeatureName() {
972
1019
  return this._parseIdent();
973
- };
974
- Parser.prototype._parseMediaFeatureValue = function () {
1020
+ }
1021
+ _parseMediaFeatureValue() {
975
1022
  return this._parseRatio() || this._parseTermExpression();
976
- };
977
- Parser.prototype._parseMedium = function () {
978
- var node = this.create(nodes.Node);
1023
+ }
1024
+ _parseMedium() {
1025
+ const node = this.create(nodes.Node);
979
1026
  if (node.addChild(this._parseIdent())) {
980
1027
  return this.finish(node);
981
1028
  }
982
1029
  else {
983
1030
  return null;
984
1031
  }
985
- };
986
- Parser.prototype._parsePageDeclaration = function () {
1032
+ }
1033
+ _parsePageDeclaration() {
987
1034
  return this._parsePageMarginBox() || this._parseRuleSetDeclaration();
988
- };
989
- Parser.prototype._parsePage = function () {
1035
+ }
1036
+ _parsePage() {
990
1037
  // http://www.w3.org/TR/css3-page/
991
1038
  // page_rule : PAGE_SYM S* page_selector_list '{' S* page_body '}' S*
992
1039
  // page_body : /* Can be empty */ declaration? [ ';' S* page_body ]? | page_margin_box page_body
993
1040
  if (!this.peekKeyword('@page')) {
994
1041
  return null;
995
1042
  }
996
- var node = this.create(nodes.Page);
1043
+ const node = this.create(nodes.Page);
997
1044
  this.consumeToken();
998
1045
  if (node.addChild(this._parsePageSelector())) {
999
1046
  while (this.accept(cssScanner_1.TokenType.Comma)) {
@@ -1003,25 +1050,25 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1003
1050
  }
1004
1051
  }
1005
1052
  return this._parseBody(node, this._parsePageDeclaration.bind(this));
1006
- };
1007
- Parser.prototype._parsePageMarginBox = function () {
1053
+ }
1054
+ _parsePageMarginBox() {
1008
1055
  // page_margin_box : margin_sym S* '{' S* declaration? [ ';' S* declaration? ]* '}' S*
1009
1056
  if (!this.peek(cssScanner_1.TokenType.AtKeyword)) {
1010
1057
  return null;
1011
1058
  }
1012
- var node = this.create(nodes.PageBoxMarginBox);
1059
+ const node = this.create(nodes.PageBoxMarginBox);
1013
1060
  if (!this.acceptOneKeyword(languageFacts.pageBoxDirectives)) {
1014
1061
  this.markError(node, cssErrors_1.ParseError.UnknownAtRule, [], [cssScanner_1.TokenType.CurlyL]);
1015
1062
  }
1016
1063
  return this._parseBody(node, this._parseRuleSetDeclaration.bind(this));
1017
- };
1018
- Parser.prototype._parsePageSelector = function () {
1064
+ }
1065
+ _parsePageSelector() {
1019
1066
  // page_selector : pseudo_page+ | IDENT pseudo_page*
1020
1067
  // pseudo_page : ':' [ "left" | "right" | "first" | "blank" ];
1021
1068
  if (!this.peek(cssScanner_1.TokenType.Ident) && !this.peek(cssScanner_1.TokenType.Colon)) {
1022
1069
  return null;
1023
1070
  }
1024
- var node = this.create(nodes.Node);
1071
+ const node = this.create(nodes.Node);
1025
1072
  node.addChild(this._parseIdent()); // optional ident
1026
1073
  if (this.accept(cssScanner_1.TokenType.Colon)) {
1027
1074
  if (!node.addChild(this._parseIdent())) { // optional ident
@@ -1029,29 +1076,29 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1029
1076
  }
1030
1077
  }
1031
1078
  return this.finish(node);
1032
- };
1033
- Parser.prototype._parseDocument = function () {
1079
+ }
1080
+ _parseDocument() {
1034
1081
  // -moz-document is experimental but has been pushed to css4
1035
1082
  if (!this.peekKeyword('@-moz-document')) {
1036
1083
  return null;
1037
1084
  }
1038
- var node = this.create(nodes.Document);
1085
+ const node = this.create(nodes.Document);
1039
1086
  this.consumeToken(); // @-moz-document
1040
1087
  this.resync([], [cssScanner_1.TokenType.CurlyL]); // ignore all the rules
1041
1088
  return this._parseBody(node, this._parseStylesheetStatement.bind(this));
1042
- };
1089
+ }
1043
1090
  // https://www.w3.org/TR/css-syntax-3/#consume-an-at-rule
1044
- Parser.prototype._parseUnknownAtRule = function () {
1091
+ _parseUnknownAtRule() {
1045
1092
  if (!this.peek(cssScanner_1.TokenType.AtKeyword)) {
1046
1093
  return null;
1047
1094
  }
1048
- var node = this.create(nodes.UnknownAtRule);
1095
+ const node = this.create(nodes.UnknownAtRule);
1049
1096
  node.addChild(this._parseUnknownAtRuleName());
1050
- var isTopLevel = function () { return curlyDepth === 0 && parensDepth === 0 && bracketsDepth === 0; };
1051
- var curlyLCount = 0;
1052
- var curlyDepth = 0;
1053
- var parensDepth = 0;
1054
- var bracketsDepth = 0;
1097
+ const isTopLevel = () => curlyDepth === 0 && parensDepth === 0 && bracketsDepth === 0;
1098
+ let curlyLCount = 0;
1099
+ let curlyDepth = 0;
1100
+ let parensDepth = 0;
1101
+ let bracketsDepth = 0;
1055
1102
  done: while (true) {
1056
1103
  switch (this.token.type) {
1057
1104
  case cssScanner_1.TokenType.SemiColon:
@@ -1120,15 +1167,15 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1120
1167
  this.consumeToken();
1121
1168
  }
1122
1169
  return node;
1123
- };
1124
- Parser.prototype._parseUnknownAtRuleName = function () {
1125
- var node = this.create(nodes.Node);
1170
+ }
1171
+ _parseUnknownAtRuleName() {
1172
+ const node = this.create(nodes.Node);
1126
1173
  if (this.accept(cssScanner_1.TokenType.AtKeyword)) {
1127
1174
  return this.finish(node);
1128
1175
  }
1129
1176
  return node;
1130
- };
1131
- Parser.prototype._parseOperator = function () {
1177
+ }
1178
+ _parseOperator() {
1132
1179
  // these are operators for binary expressions
1133
1180
  if (this.peekDelim('/') ||
1134
1181
  this.peekDelim('*') ||
@@ -1140,27 +1187,27 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1140
1187
  this.peek(cssScanner_1.TokenType.PrefixOperator) ||
1141
1188
  this.peek(cssScanner_1.TokenType.SuffixOperator) ||
1142
1189
  this.peekDelim('=')) { // doesn't stick to the standard here
1143
- var node = this.createNode(nodes.NodeType.Operator);
1190
+ const node = this.createNode(nodes.NodeType.Operator);
1144
1191
  this.consumeToken();
1145
1192
  return this.finish(node);
1146
1193
  }
1147
1194
  else {
1148
1195
  return null;
1149
1196
  }
1150
- };
1151
- Parser.prototype._parseUnaryOperator = function () {
1197
+ }
1198
+ _parseUnaryOperator() {
1152
1199
  if (!this.peekDelim('+') && !this.peekDelim('-')) {
1153
1200
  return null;
1154
1201
  }
1155
- var node = this.create(nodes.Node);
1202
+ const node = this.create(nodes.Node);
1156
1203
  this.consumeToken();
1157
1204
  return this.finish(node);
1158
- };
1159
- Parser.prototype._parseCombinator = function () {
1205
+ }
1206
+ _parseCombinator() {
1160
1207
  if (this.peekDelim('>')) {
1161
- var node = this.create(nodes.Node);
1208
+ const node = this.create(nodes.Node);
1162
1209
  this.consumeToken();
1163
- var mark = this.mark();
1210
+ const mark = this.mark();
1164
1211
  if (!this.hasWhitespace() && this.acceptDelim('>')) {
1165
1212
  if (!this.hasWhitespace() && this.acceptDelim('>')) {
1166
1213
  node.type = nodes.NodeType.SelectorCombinatorShadowPiercingDescendant;
@@ -1172,21 +1219,21 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1172
1219
  return this.finish(node);
1173
1220
  }
1174
1221
  else if (this.peekDelim('+')) {
1175
- var node = this.create(nodes.Node);
1222
+ const node = this.create(nodes.Node);
1176
1223
  this.consumeToken();
1177
1224
  node.type = nodes.NodeType.SelectorCombinatorSibling;
1178
1225
  return this.finish(node);
1179
1226
  }
1180
1227
  else if (this.peekDelim('~')) {
1181
- var node = this.create(nodes.Node);
1228
+ const node = this.create(nodes.Node);
1182
1229
  this.consumeToken();
1183
1230
  node.type = nodes.NodeType.SelectorCombinatorAllSiblings;
1184
1231
  return this.finish(node);
1185
1232
  }
1186
1233
  else if (this.peekDelim('/')) {
1187
- var node = this.create(nodes.Node);
1234
+ const node = this.create(nodes.Node);
1188
1235
  this.consumeToken();
1189
- var mark = this.mark();
1236
+ const mark = this.mark();
1190
1237
  if (!this.hasWhitespace() && this.acceptIdent('deep') && !this.hasWhitespace() && this.acceptDelim('/')) {
1191
1238
  node.type = nodes.NodeType.SelectorCombinatorShadowPiercingDescendant;
1192
1239
  return this.finish(node);
@@ -1194,12 +1241,12 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1194
1241
  this.restoreAtMark(mark);
1195
1242
  }
1196
1243
  return null;
1197
- };
1198
- Parser.prototype._parseSimpleSelector = function () {
1244
+ }
1245
+ _parseSimpleSelector() {
1199
1246
  // simple_selector
1200
1247
  // : element_name [ HASH | class | attrib | pseudo ]* | [ HASH | class | attrib | pseudo ]+ ;
1201
- var node = this.create(nodes.SimpleSelector);
1202
- var c = 0;
1248
+ const node = this.create(nodes.SimpleSelector);
1249
+ let c = 0;
1203
1250
  if (node.addChild(this._parseElementName())) {
1204
1251
  c++;
1205
1252
  }
@@ -1207,18 +1254,18 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1207
1254
  c++;
1208
1255
  }
1209
1256
  return c > 0 ? this.finish(node) : null;
1210
- };
1211
- Parser.prototype._parseSimpleSelectorBody = function () {
1257
+ }
1258
+ _parseSimpleSelectorBody() {
1212
1259
  return this._parsePseudo() || this._parseHash() || this._parseClass() || this._parseAttrib();
1213
- };
1214
- Parser.prototype._parseSelectorIdent = function () {
1260
+ }
1261
+ _parseSelectorIdent() {
1215
1262
  return this._parseIdent();
1216
- };
1217
- Parser.prototype._parseHash = function () {
1263
+ }
1264
+ _parseHash() {
1218
1265
  if (!this.peek(cssScanner_1.TokenType.Hash) && !this.peekDelim('#')) {
1219
1266
  return null;
1220
1267
  }
1221
- var node = this.createNode(nodes.NodeType.IdentifierSelector);
1268
+ const node = this.createNode(nodes.NodeType.IdentifierSelector);
1222
1269
  if (this.acceptDelim('#')) {
1223
1270
  if (this.hasWhitespace() || !node.addChild(this._parseSelectorIdent())) {
1224
1271
  return this.finish(node, cssErrors_1.ParseError.IdentifierExpected);
@@ -1228,33 +1275,33 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1228
1275
  this.consumeToken(); // TokenType.Hash
1229
1276
  }
1230
1277
  return this.finish(node);
1231
- };
1232
- Parser.prototype._parseClass = function () {
1278
+ }
1279
+ _parseClass() {
1233
1280
  // class: '.' IDENT ;
1234
1281
  if (!this.peekDelim('.')) {
1235
1282
  return null;
1236
1283
  }
1237
- var node = this.createNode(nodes.NodeType.ClassSelector);
1284
+ const node = this.createNode(nodes.NodeType.ClassSelector);
1238
1285
  this.consumeToken(); // '.'
1239
1286
  if (this.hasWhitespace() || !node.addChild(this._parseSelectorIdent())) {
1240
1287
  return this.finish(node, cssErrors_1.ParseError.IdentifierExpected);
1241
1288
  }
1242
1289
  return this.finish(node);
1243
- };
1244
- Parser.prototype._parseElementName = function () {
1290
+ }
1291
+ _parseElementName() {
1245
1292
  // element_name: (ns? '|')? IDENT | '*';
1246
- var pos = this.mark();
1247
- var node = this.createNode(nodes.NodeType.ElementNameSelector);
1293
+ const pos = this.mark();
1294
+ const node = this.createNode(nodes.NodeType.ElementNameSelector);
1248
1295
  node.addChild(this._parseNamespacePrefix());
1249
1296
  if (!node.addChild(this._parseSelectorIdent()) && !this.acceptDelim('*')) {
1250
1297
  this.restoreAtMark(pos);
1251
1298
  return null;
1252
1299
  }
1253
1300
  return this.finish(node);
1254
- };
1255
- Parser.prototype._parseNamespacePrefix = function () {
1256
- var pos = this.mark();
1257
- var node = this.createNode(nodes.NodeType.NamespacePrefix);
1301
+ }
1302
+ _parseNamespacePrefix() {
1303
+ const pos = this.mark();
1304
+ const node = this.createNode(nodes.NodeType.NamespacePrefix);
1258
1305
  if (!node.addChild(this._parseIdent()) && !this.acceptDelim('*')) {
1259
1306
  // ns is optional
1260
1307
  }
@@ -1263,13 +1310,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1263
1310
  return null;
1264
1311
  }
1265
1312
  return this.finish(node);
1266
- };
1267
- Parser.prototype._parseAttrib = function () {
1313
+ }
1314
+ _parseAttrib() {
1268
1315
  // attrib : '[' S* IDENT S* [ [ '=' | INCLUDES | DASHMATCH ] S* [ IDENT | STRING ] S* ]? ']'
1269
1316
  if (!this.peek(cssScanner_1.TokenType.BracketL)) {
1270
1317
  return null;
1271
1318
  }
1272
- var node = this.create(nodes.AttributeSelector);
1319
+ const node = this.create(nodes.AttributeSelector);
1273
1320
  this.consumeToken(); // BracketL
1274
1321
  // Optional attrib namespace
1275
1322
  node.setNamespacePrefix(this._parseNamespacePrefix());
@@ -1285,23 +1332,22 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1285
1332
  return this.finish(node, cssErrors_1.ParseError.RightSquareBracketExpected);
1286
1333
  }
1287
1334
  return this.finish(node);
1288
- };
1289
- Parser.prototype._parsePseudo = function () {
1290
- var _this = this;
1335
+ }
1336
+ _parsePseudo() {
1291
1337
  // pseudo: ':' [ IDENT | FUNCTION S* [IDENT S*]? ')' ]
1292
- var node = this._tryParsePseudoIdentifier();
1338
+ const node = this._tryParsePseudoIdentifier();
1293
1339
  if (node) {
1294
1340
  if (!this.hasWhitespace() && this.accept(cssScanner_1.TokenType.ParenthesisL)) {
1295
- var tryAsSelector = function () {
1296
- var selectors = _this.create(nodes.Node);
1297
- if (!selectors.addChild(_this._parseSelector(false))) {
1341
+ const tryAsSelector = () => {
1342
+ const selectors = this.create(nodes.Node);
1343
+ if (!selectors.addChild(this._parseSelector(true))) {
1298
1344
  return null;
1299
1345
  }
1300
- while (_this.accept(cssScanner_1.TokenType.Comma) && selectors.addChild(_this._parseSelector(false))) {
1346
+ while (this.accept(cssScanner_1.TokenType.Comma) && selectors.addChild(this._parseSelector(true))) {
1301
1347
  // loop
1302
1348
  }
1303
- if (_this.peek(cssScanner_1.TokenType.ParenthesisR)) {
1304
- return _this.finish(selectors);
1349
+ if (this.peek(cssScanner_1.TokenType.ParenthesisR)) {
1350
+ return this.finish(selectors);
1305
1351
  }
1306
1352
  return null;
1307
1353
  };
@@ -1313,13 +1359,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1313
1359
  return this.finish(node);
1314
1360
  }
1315
1361
  return null;
1316
- };
1317
- Parser.prototype._tryParsePseudoIdentifier = function () {
1362
+ }
1363
+ _tryParsePseudoIdentifier() {
1318
1364
  if (!this.peek(cssScanner_1.TokenType.Colon)) {
1319
1365
  return null;
1320
1366
  }
1321
- var pos = this.mark();
1322
- var node = this.createNode(nodes.NodeType.PseudoSelector);
1367
+ const pos = this.mark();
1368
+ const node = this.createNode(nodes.NodeType.PseudoSelector);
1323
1369
  this.consumeToken(); // Colon
1324
1370
  if (this.hasWhitespace()) {
1325
1371
  this.restoreAtMark(pos);
@@ -1331,29 +1377,28 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1331
1377
  return this.finish(node, cssErrors_1.ParseError.IdentifierExpected);
1332
1378
  }
1333
1379
  return this.finish(node);
1334
- };
1335
- Parser.prototype._tryParsePrio = function () {
1336
- var mark = this.mark();
1337
- var prio = this._parsePrio();
1380
+ }
1381
+ _tryParsePrio() {
1382
+ const mark = this.mark();
1383
+ const prio = this._parsePrio();
1338
1384
  if (prio) {
1339
1385
  return prio;
1340
1386
  }
1341
1387
  this.restoreAtMark(mark);
1342
1388
  return null;
1343
- };
1344
- Parser.prototype._parsePrio = function () {
1389
+ }
1390
+ _parsePrio() {
1345
1391
  if (!this.peek(cssScanner_1.TokenType.Exclamation)) {
1346
1392
  return null;
1347
1393
  }
1348
- var node = this.createNode(nodes.NodeType.Prio);
1394
+ const node = this.createNode(nodes.NodeType.Prio);
1349
1395
  if (this.accept(cssScanner_1.TokenType.Exclamation) && this.acceptIdent('important')) {
1350
1396
  return this.finish(node);
1351
1397
  }
1352
1398
  return null;
1353
- };
1354
- Parser.prototype._parseExpr = function (stopOnComma) {
1355
- if (stopOnComma === void 0) { stopOnComma = false; }
1356
- var node = this.create(nodes.Expression);
1399
+ }
1400
+ _parseExpr(stopOnComma = false) {
1401
+ const node = this.create(nodes.Expression);
1357
1402
  if (!node.addChild(this._parseBinaryExpr())) {
1358
1403
  return null;
1359
1404
  }
@@ -1369,23 +1414,23 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1369
1414
  }
1370
1415
  }
1371
1416
  return this.finish(node);
1372
- };
1373
- Parser.prototype._parseUnicodeRange = function () {
1417
+ }
1418
+ _parseUnicodeRange() {
1374
1419
  if (!this.peekIdent('u')) {
1375
1420
  return null;
1376
1421
  }
1377
- var node = this.create(nodes.UnicodeRange);
1422
+ const node = this.create(nodes.UnicodeRange);
1378
1423
  if (!this.acceptUnicodeRange()) {
1379
1424
  return null;
1380
1425
  }
1381
1426
  return this.finish(node);
1382
- };
1383
- Parser.prototype._parseNamedLine = function () {
1427
+ }
1428
+ _parseNamedLine() {
1384
1429
  // https://www.w3.org/TR/css-grid-1/#named-lines
1385
1430
  if (!this.peek(cssScanner_1.TokenType.BracketL)) {
1386
1431
  return null;
1387
1432
  }
1388
- var node = this.createNode(nodes.NodeType.GridLine);
1433
+ const node = this.createNode(nodes.NodeType.GridLine);
1389
1434
  this.consumeToken();
1390
1435
  while (node.addChild(this._parseIdent())) {
1391
1436
  // repeat
@@ -1394,9 +1439,9 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1394
1439
  return this.finish(node, cssErrors_1.ParseError.RightSquareBracketExpected);
1395
1440
  }
1396
1441
  return this.finish(node);
1397
- };
1398
- Parser.prototype._parseBinaryExpr = function (preparsedLeft, preparsedOper) {
1399
- var node = this.create(nodes.BinaryExpression);
1442
+ }
1443
+ _parseBinaryExpr(preparsedLeft, preparsedOper) {
1444
+ let node = this.create(nodes.BinaryExpression);
1400
1445
  if (!node.setLeft((preparsedLeft || this._parseTerm()))) {
1401
1446
  return null;
1402
1447
  }
@@ -1408,21 +1453,21 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1408
1453
  }
1409
1454
  // things needed for multiple binary expressions
1410
1455
  node = this.finish(node);
1411
- var operator = this._parseOperator();
1456
+ const operator = this._parseOperator();
1412
1457
  if (operator) {
1413
1458
  node = this._parseBinaryExpr(node, operator);
1414
1459
  }
1415
1460
  return this.finish(node);
1416
- };
1417
- Parser.prototype._parseTerm = function () {
1418
- var node = this.create(nodes.Term);
1461
+ }
1462
+ _parseTerm() {
1463
+ let node = this.create(nodes.Term);
1419
1464
  node.setOperator(this._parseUnaryOperator()); // optional
1420
1465
  if (node.setExpression(this._parseTermExpression())) {
1421
1466
  return this.finish(node);
1422
1467
  }
1423
1468
  return null;
1424
- };
1425
- Parser.prototype._parseTermExpression = function () {
1469
+ }
1470
+ _parseTermExpression() {
1426
1471
  return this._parseURILiteral() || // url before function
1427
1472
  this._parseUnicodeRange() ||
1428
1473
  this._parseFunction() || // function before ident
@@ -1432,20 +1477,20 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1432
1477
  this._parseHexColor() ||
1433
1478
  this._parseOperation() ||
1434
1479
  this._parseNamedLine();
1435
- };
1436
- Parser.prototype._parseOperation = function () {
1480
+ }
1481
+ _parseOperation() {
1437
1482
  if (!this.peek(cssScanner_1.TokenType.ParenthesisL)) {
1438
1483
  return null;
1439
1484
  }
1440
- var node = this.create(nodes.Node);
1485
+ const node = this.create(nodes.Node);
1441
1486
  this.consumeToken(); // ParenthesisL
1442
1487
  node.addChild(this._parseExpr());
1443
1488
  if (!this.accept(cssScanner_1.TokenType.ParenthesisR)) {
1444
1489
  return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected);
1445
1490
  }
1446
1491
  return this.finish(node);
1447
- };
1448
- Parser.prototype._parseNumeric = function () {
1492
+ }
1493
+ _parseNumeric() {
1449
1494
  if (this.peek(cssScanner_1.TokenType.Num) ||
1450
1495
  this.peek(cssScanner_1.TokenType.Percentage) ||
1451
1496
  this.peek(cssScanner_1.TokenType.Resolution) ||
@@ -1456,26 +1501,26 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1456
1501
  this.peek(cssScanner_1.TokenType.Time) ||
1457
1502
  this.peek(cssScanner_1.TokenType.Dimension) ||
1458
1503
  this.peek(cssScanner_1.TokenType.Freq)) {
1459
- var node = this.create(nodes.NumericValue);
1504
+ const node = this.create(nodes.NumericValue);
1460
1505
  this.consumeToken();
1461
1506
  return this.finish(node);
1462
1507
  }
1463
1508
  return null;
1464
- };
1465
- Parser.prototype._parseStringLiteral = function () {
1509
+ }
1510
+ _parseStringLiteral() {
1466
1511
  if (!this.peek(cssScanner_1.TokenType.String) && !this.peek(cssScanner_1.TokenType.BadString)) {
1467
1512
  return null;
1468
1513
  }
1469
- var node = this.createNode(nodes.NodeType.StringLiteral);
1514
+ const node = this.createNode(nodes.NodeType.StringLiteral);
1470
1515
  this.consumeToken();
1471
1516
  return this.finish(node);
1472
- };
1473
- Parser.prototype._parseURILiteral = function () {
1517
+ }
1518
+ _parseURILiteral() {
1474
1519
  if (!this.peekRegExp(cssScanner_1.TokenType.Ident, /^url(-prefix)?$/i)) {
1475
1520
  return null;
1476
1521
  }
1477
- var pos = this.mark();
1478
- var node = this.createNode(nodes.NodeType.URILiteral);
1522
+ const pos = this.mark();
1523
+ const node = this.createNode(nodes.NodeType.URILiteral);
1479
1524
  this.accept(cssScanner_1.TokenType.Ident);
1480
1525
  if (this.hasWhitespace() || !this.peek(cssScanner_1.TokenType.ParenthesisL)) {
1481
1526
  this.restoreAtMark(pos);
@@ -1489,29 +1534,29 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1489
1534
  return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected);
1490
1535
  }
1491
1536
  return this.finish(node);
1492
- };
1493
- Parser.prototype._parseURLArgument = function () {
1494
- var node = this.create(nodes.Node);
1537
+ }
1538
+ _parseURLArgument() {
1539
+ const node = this.create(nodes.Node);
1495
1540
  if (!this.accept(cssScanner_1.TokenType.String) && !this.accept(cssScanner_1.TokenType.BadString) && !this.acceptUnquotedString()) {
1496
1541
  return null;
1497
1542
  }
1498
1543
  return this.finish(node);
1499
- };
1500
- Parser.prototype._parseIdent = function (referenceTypes) {
1544
+ }
1545
+ _parseIdent(referenceTypes) {
1501
1546
  if (!this.peek(cssScanner_1.TokenType.Ident)) {
1502
1547
  return null;
1503
1548
  }
1504
- var node = this.create(nodes.Identifier);
1549
+ const node = this.create(nodes.Identifier);
1505
1550
  if (referenceTypes) {
1506
1551
  node.referenceTypes = referenceTypes;
1507
1552
  }
1508
1553
  node.isCustomProperty = this.peekRegExp(cssScanner_1.TokenType.Ident, /^--/);
1509
1554
  this.consumeToken();
1510
1555
  return this.finish(node);
1511
- };
1512
- Parser.prototype._parseFunction = function () {
1513
- var pos = this.mark();
1514
- var node = this.create(nodes.Function);
1556
+ }
1557
+ _parseFunction() {
1558
+ const pos = this.mark();
1559
+ const node = this.create(nodes.Function);
1515
1560
  if (!node.setIdentifier(this._parseFunctionIdentifier())) {
1516
1561
  return null;
1517
1562
  }
@@ -1533,12 +1578,12 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1533
1578
  return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected);
1534
1579
  }
1535
1580
  return this.finish(node);
1536
- };
1537
- Parser.prototype._parseFunctionIdentifier = function () {
1581
+ }
1582
+ _parseFunctionIdentifier() {
1538
1583
  if (!this.peek(cssScanner_1.TokenType.Ident)) {
1539
1584
  return null;
1540
1585
  }
1541
- var node = this.create(nodes.Identifier);
1586
+ const node = this.create(nodes.Identifier);
1542
1587
  node.referenceTypes = [nodes.ReferenceType.Function];
1543
1588
  if (this.acceptIdent('progid')) {
1544
1589
  // support for IE7 specific filters: 'progid:DXImageTransform.Microsoft.MotionBlur(strength=13, direction=310)'
@@ -1551,25 +1596,24 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1551
1596
  }
1552
1597
  this.consumeToken();
1553
1598
  return this.finish(node);
1554
- };
1555
- Parser.prototype._parseFunctionArgument = function () {
1556
- var node = this.create(nodes.FunctionArgument);
1599
+ }
1600
+ _parseFunctionArgument() {
1601
+ const node = this.create(nodes.FunctionArgument);
1557
1602
  if (node.setValue(this._parseExpr(true))) {
1558
1603
  return this.finish(node);
1559
1604
  }
1560
1605
  return null;
1561
- };
1562
- Parser.prototype._parseHexColor = function () {
1606
+ }
1607
+ _parseHexColor() {
1563
1608
  if (this.peekRegExp(cssScanner_1.TokenType.Hash, /^#([A-Fa-f0-9]{3}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/g)) {
1564
- var node = this.create(nodes.HexColorValue);
1609
+ const node = this.create(nodes.HexColorValue);
1565
1610
  this.consumeToken();
1566
1611
  return this.finish(node);
1567
1612
  }
1568
1613
  else {
1569
1614
  return null;
1570
1615
  }
1571
- };
1572
- return Parser;
1573
- }());
1616
+ }
1617
+ }
1574
1618
  exports.Parser = Parser;
1575
1619
  });