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
@@ -60,54 +60,51 @@
60
60
  TokenType[TokenType["EOF"] = 41] = "EOF";
61
61
  TokenType[TokenType["CustomToken"] = 42] = "CustomToken";
62
62
  })(TokenType = exports.TokenType || (exports.TokenType = {}));
63
- var MultiLineStream = /** @class */ (function () {
64
- function MultiLineStream(source) {
63
+ class MultiLineStream {
64
+ constructor(source) {
65
65
  this.source = source;
66
66
  this.len = source.length;
67
67
  this.position = 0;
68
68
  }
69
- MultiLineStream.prototype.substring = function (from, to) {
70
- if (to === void 0) { to = this.position; }
69
+ substring(from, to = this.position) {
71
70
  return this.source.substring(from, to);
72
- };
73
- MultiLineStream.prototype.eos = function () {
71
+ }
72
+ eos() {
74
73
  return this.len <= this.position;
75
- };
76
- MultiLineStream.prototype.pos = function () {
74
+ }
75
+ pos() {
77
76
  return this.position;
78
- };
79
- MultiLineStream.prototype.goBackTo = function (pos) {
77
+ }
78
+ goBackTo(pos) {
80
79
  this.position = pos;
81
- };
82
- MultiLineStream.prototype.goBack = function (n) {
80
+ }
81
+ goBack(n) {
83
82
  this.position -= n;
84
- };
85
- MultiLineStream.prototype.advance = function (n) {
83
+ }
84
+ advance(n) {
86
85
  this.position += n;
87
- };
88
- MultiLineStream.prototype.nextChar = function () {
86
+ }
87
+ nextChar() {
89
88
  return this.source.charCodeAt(this.position++) || 0;
90
- };
91
- MultiLineStream.prototype.peekChar = function (n) {
92
- if (n === void 0) { n = 0; }
89
+ }
90
+ peekChar(n = 0) {
93
91
  return this.source.charCodeAt(this.position + n) || 0;
94
- };
95
- MultiLineStream.prototype.lookbackChar = function (n) {
96
- if (n === void 0) { n = 0; }
92
+ }
93
+ lookbackChar(n = 0) {
97
94
  return this.source.charCodeAt(this.position - n) || 0;
98
- };
99
- MultiLineStream.prototype.advanceIfChar = function (ch) {
95
+ }
96
+ advanceIfChar(ch) {
100
97
  if (ch === this.source.charCodeAt(this.position)) {
101
98
  this.position++;
102
99
  return true;
103
100
  }
104
101
  return false;
105
- };
106
- MultiLineStream.prototype.advanceIfChars = function (ch) {
102
+ }
103
+ advanceIfChars(ch) {
107
104
  if (this.position + ch.length > this.source.length) {
108
105
  return false;
109
106
  }
110
- var i = 0;
107
+ let i = 0;
111
108
  for (; i < ch.length; i++) {
112
109
  if (this.source.charCodeAt(this.position + i) !== ch[i]) {
113
110
  return false;
@@ -115,62 +112,61 @@
115
112
  }
116
113
  this.advance(i);
117
114
  return true;
118
- };
119
- MultiLineStream.prototype.advanceWhileChar = function (condition) {
120
- var posNow = this.position;
115
+ }
116
+ advanceWhileChar(condition) {
117
+ const posNow = this.position;
121
118
  while (this.position < this.len && condition(this.source.charCodeAt(this.position))) {
122
119
  this.position++;
123
120
  }
124
121
  return this.position - posNow;
125
- };
126
- return MultiLineStream;
127
- }());
122
+ }
123
+ }
128
124
  exports.MultiLineStream = MultiLineStream;
129
- var _a = 'a'.charCodeAt(0);
130
- var _f = 'f'.charCodeAt(0);
131
- var _z = 'z'.charCodeAt(0);
132
- var _u = 'u'.charCodeAt(0);
133
- var _A = 'A'.charCodeAt(0);
134
- var _F = 'F'.charCodeAt(0);
135
- var _Z = 'Z'.charCodeAt(0);
136
- var _0 = '0'.charCodeAt(0);
137
- var _9 = '9'.charCodeAt(0);
138
- var _TLD = '~'.charCodeAt(0);
139
- var _HAT = '^'.charCodeAt(0);
140
- var _EQS = '='.charCodeAt(0);
141
- var _PIP = '|'.charCodeAt(0);
142
- var _MIN = '-'.charCodeAt(0);
143
- var _USC = '_'.charCodeAt(0);
144
- var _PRC = '%'.charCodeAt(0);
145
- var _MUL = '*'.charCodeAt(0);
146
- var _LPA = '('.charCodeAt(0);
147
- var _RPA = ')'.charCodeAt(0);
148
- var _LAN = '<'.charCodeAt(0);
149
- var _RAN = '>'.charCodeAt(0);
150
- var _ATS = '@'.charCodeAt(0);
151
- var _HSH = '#'.charCodeAt(0);
152
- var _DLR = '$'.charCodeAt(0);
153
- var _BSL = '\\'.charCodeAt(0);
154
- var _FSL = '/'.charCodeAt(0);
155
- var _NWL = '\n'.charCodeAt(0);
156
- var _CAR = '\r'.charCodeAt(0);
157
- var _LFD = '\f'.charCodeAt(0);
158
- var _DQO = '"'.charCodeAt(0);
159
- var _SQO = '\''.charCodeAt(0);
160
- var _WSP = ' '.charCodeAt(0);
161
- var _TAB = '\t'.charCodeAt(0);
162
- var _SEM = ';'.charCodeAt(0);
163
- var _COL = ':'.charCodeAt(0);
164
- var _CUL = '{'.charCodeAt(0);
165
- var _CUR = '}'.charCodeAt(0);
166
- var _BRL = '['.charCodeAt(0);
167
- var _BRR = ']'.charCodeAt(0);
168
- var _CMA = ','.charCodeAt(0);
169
- var _DOT = '.'.charCodeAt(0);
170
- var _BNG = '!'.charCodeAt(0);
171
- var _QSM = '?'.charCodeAt(0);
172
- var _PLS = '+'.charCodeAt(0);
173
- var staticTokenTable = {};
125
+ const _a = 'a'.charCodeAt(0);
126
+ const _f = 'f'.charCodeAt(0);
127
+ const _z = 'z'.charCodeAt(0);
128
+ const _u = 'u'.charCodeAt(0);
129
+ const _A = 'A'.charCodeAt(0);
130
+ const _F = 'F'.charCodeAt(0);
131
+ const _Z = 'Z'.charCodeAt(0);
132
+ const _0 = '0'.charCodeAt(0);
133
+ const _9 = '9'.charCodeAt(0);
134
+ const _TLD = '~'.charCodeAt(0);
135
+ const _HAT = '^'.charCodeAt(0);
136
+ const _EQS = '='.charCodeAt(0);
137
+ const _PIP = '|'.charCodeAt(0);
138
+ const _MIN = '-'.charCodeAt(0);
139
+ const _USC = '_'.charCodeAt(0);
140
+ const _PRC = '%'.charCodeAt(0);
141
+ const _MUL = '*'.charCodeAt(0);
142
+ const _LPA = '('.charCodeAt(0);
143
+ const _RPA = ')'.charCodeAt(0);
144
+ const _LAN = '<'.charCodeAt(0);
145
+ const _RAN = '>'.charCodeAt(0);
146
+ const _ATS = '@'.charCodeAt(0);
147
+ const _HSH = '#'.charCodeAt(0);
148
+ const _DLR = '$'.charCodeAt(0);
149
+ const _BSL = '\\'.charCodeAt(0);
150
+ const _FSL = '/'.charCodeAt(0);
151
+ const _NWL = '\n'.charCodeAt(0);
152
+ const _CAR = '\r'.charCodeAt(0);
153
+ const _LFD = '\f'.charCodeAt(0);
154
+ const _DQO = '"'.charCodeAt(0);
155
+ const _SQO = '\''.charCodeAt(0);
156
+ const _WSP = ' '.charCodeAt(0);
157
+ const _TAB = '\t'.charCodeAt(0);
158
+ const _SEM = ';'.charCodeAt(0);
159
+ const _COL = ':'.charCodeAt(0);
160
+ const _CUL = '{'.charCodeAt(0);
161
+ const _CUR = '}'.charCodeAt(0);
162
+ const _BRL = '['.charCodeAt(0);
163
+ const _BRR = ']'.charCodeAt(0);
164
+ const _CMA = ','.charCodeAt(0);
165
+ const _DOT = '.'.charCodeAt(0);
166
+ const _BNG = '!'.charCodeAt(0);
167
+ const _QSM = '?'.charCodeAt(0);
168
+ const _PLS = '+'.charCodeAt(0);
169
+ const staticTokenTable = {};
174
170
  staticTokenTable[_SEM] = TokenType.SemiColon;
175
171
  staticTokenTable[_COL] = TokenType.Colon;
176
172
  staticTokenTable[_CUL] = TokenType.CurlyL;
@@ -180,7 +176,7 @@
180
176
  staticTokenTable[_LPA] = TokenType.ParenthesisL;
181
177
  staticTokenTable[_RPA] = TokenType.ParenthesisR;
182
178
  staticTokenTable[_CMA] = TokenType.Comma;
183
- var staticUnitTable = {};
179
+ const staticUnitTable = {};
184
180
  staticUnitTable['em'] = TokenType.EMS;
185
181
  staticUnitTable['ex'] = TokenType.EXS;
186
182
  staticUnitTable['px'] = TokenType.Length;
@@ -200,68 +196,68 @@
200
196
  staticUnitTable['fr'] = TokenType.Percentage;
201
197
  staticUnitTable['dpi'] = TokenType.Resolution;
202
198
  staticUnitTable['dpcm'] = TokenType.Resolution;
203
- var Scanner = /** @class */ (function () {
204
- function Scanner() {
199
+ class Scanner {
200
+ constructor() {
205
201
  this.stream = new MultiLineStream('');
206
202
  this.ignoreComment = true;
207
203
  this.ignoreWhitespace = true;
208
204
  this.inURL = false;
209
205
  }
210
- Scanner.prototype.setSource = function (input) {
206
+ setSource(input) {
211
207
  this.stream = new MultiLineStream(input);
212
- };
213
- Scanner.prototype.finishToken = function (offset, type, text) {
208
+ }
209
+ finishToken(offset, type, text) {
214
210
  return {
215
211
  offset: offset,
216
212
  len: this.stream.pos() - offset,
217
213
  type: type,
218
214
  text: text || this.stream.substring(offset)
219
215
  };
220
- };
221
- Scanner.prototype.substring = function (offset, len) {
216
+ }
217
+ substring(offset, len) {
222
218
  return this.stream.substring(offset, offset + len);
223
- };
224
- Scanner.prototype.pos = function () {
219
+ }
220
+ pos() {
225
221
  return this.stream.pos();
226
- };
227
- Scanner.prototype.goBackTo = function (pos) {
222
+ }
223
+ goBackTo(pos) {
228
224
  this.stream.goBackTo(pos);
229
- };
230
- Scanner.prototype.scanUnquotedString = function () {
231
- var offset = this.stream.pos();
232
- var content = [];
225
+ }
226
+ scanUnquotedString() {
227
+ const offset = this.stream.pos();
228
+ const content = [];
233
229
  if (this._unquotedString(content)) {
234
230
  return this.finishToken(offset, TokenType.UnquotedString, content.join(''));
235
231
  }
236
232
  return null;
237
- };
238
- Scanner.prototype.scan = function () {
233
+ }
234
+ scan() {
239
235
  // processes all whitespaces and comments
240
- var triviaToken = this.trivia();
236
+ const triviaToken = this.trivia();
241
237
  if (triviaToken !== null) {
242
238
  return triviaToken;
243
239
  }
244
- var offset = this.stream.pos();
240
+ const offset = this.stream.pos();
245
241
  // End of file/input
246
242
  if (this.stream.eos()) {
247
243
  return this.finishToken(offset, TokenType.EOF);
248
244
  }
249
245
  return this.scanNext(offset);
250
- };
246
+ }
251
247
  /**
252
248
  * Read the range as described in https://www.w3.org/TR/CSS21/syndata.html#tokenization
253
249
  * Assume the `u` has aleady been consumed
254
250
  * @returns if reading the unicode was successful
255
251
  */
256
- Scanner.prototype.tryScanUnicode = function () {
257
- var offset = this.stream.pos();
252
+ tryScanUnicode() {
253
+ const offset = this.stream.pos();
258
254
  if (!this.stream.eos() && this._unicodeRange()) {
259
255
  return this.finishToken(offset, TokenType.UnicodeRange);
260
256
  }
261
257
  this.stream.goBackTo(offset);
262
258
  return undefined;
263
- };
264
- Scanner.prototype.scanNext = function (offset) {
259
+ }
260
+ scanNext(offset) {
265
261
  // CDO <!--
266
262
  if (this.stream.advanceIfChars([_LAN, _BNG, _MIN, _MIN])) {
267
263
  return this.finishToken(offset, TokenType.CDO);
@@ -270,7 +266,7 @@
270
266
  if (this.stream.advanceIfChars([_MIN, _MIN, _RAN])) {
271
267
  return this.finishToken(offset, TokenType.CDC);
272
268
  }
273
- var content = [];
269
+ let content = [];
274
270
  if (this.ident(content)) {
275
271
  return this.finishToken(offset, TokenType.Ident, content.join(''));
276
272
  }
@@ -278,7 +274,7 @@
278
274
  if (this.stream.advanceIfChar(_ATS)) {
279
275
  content = ['@'];
280
276
  if (this._name(content)) {
281
- var keywordText = content.join('');
277
+ const keywordText = content.join('');
282
278
  if (keywordText === '@charset') {
283
279
  return this.finishToken(offset, TokenType.Charset, keywordText);
284
280
  }
@@ -304,18 +300,18 @@
304
300
  }
305
301
  // Numbers
306
302
  if (this._number()) {
307
- var pos = this.stream.pos();
303
+ const pos = this.stream.pos();
308
304
  content = [this.stream.substring(offset, pos)];
309
305
  if (this.stream.advanceIfChar(_PRC)) {
310
306
  // Percentage 43%
311
307
  return this.finishToken(offset, TokenType.Percentage);
312
308
  }
313
309
  else if (this.ident(content)) {
314
- var dim = this.stream.substring(pos).toLowerCase();
315
- var tokenType_1 = staticUnitTable[dim];
316
- if (typeof tokenType_1 !== 'undefined') {
310
+ const dim = this.stream.substring(pos).toLowerCase();
311
+ const tokenType = staticUnitTable[dim];
312
+ if (typeof tokenType !== 'undefined') {
317
313
  // Known dimension 43px
318
- return this.finishToken(offset, tokenType_1, content.join(''));
314
+ return this.finishToken(offset, tokenType, content.join(''));
319
315
  }
320
316
  else {
321
317
  // Unknown dimension 43ft
@@ -326,7 +322,7 @@
326
322
  }
327
323
  // String, BadString
328
324
  content = [];
329
- var tokenType = this._string(content);
325
+ let tokenType = this._string(content);
330
326
  if (tokenType !== null) {
331
327
  return this.finishToken(offset, tokenType, content.join(''));
332
328
  }
@@ -364,10 +360,10 @@
364
360
  // Delim
365
361
  this.stream.nextChar();
366
362
  return this.finishToken(offset, TokenType.Delim);
367
- };
368
- Scanner.prototype.trivia = function () {
363
+ }
364
+ trivia() {
369
365
  while (true) {
370
- var offset = this.stream.pos();
366
+ const offset = this.stream.pos();
371
367
  if (this._whitespace()) {
372
368
  if (!this.ignoreWhitespace) {
373
369
  return this.finishToken(offset, TokenType.Whitespace);
@@ -382,42 +378,42 @@
382
378
  return null;
383
379
  }
384
380
  }
385
- };
386
- Scanner.prototype.comment = function () {
381
+ }
382
+ comment() {
387
383
  if (this.stream.advanceIfChars([_FSL, _MUL])) {
388
- var success_1 = false, hot_1 = false;
389
- this.stream.advanceWhileChar(function (ch) {
390
- if (hot_1 && ch === _FSL) {
391
- success_1 = true;
384
+ let success = false, hot = false;
385
+ this.stream.advanceWhileChar((ch) => {
386
+ if (hot && ch === _FSL) {
387
+ success = true;
392
388
  return false;
393
389
  }
394
- hot_1 = ch === _MUL;
390
+ hot = ch === _MUL;
395
391
  return true;
396
392
  });
397
- if (success_1) {
393
+ if (success) {
398
394
  this.stream.advance(1);
399
395
  }
400
396
  return true;
401
397
  }
402
398
  return false;
403
- };
404
- Scanner.prototype._number = function () {
405
- var npeek = 0, ch;
399
+ }
400
+ _number() {
401
+ let npeek = 0, ch;
406
402
  if (this.stream.peekChar() === _DOT) {
407
403
  npeek = 1;
408
404
  }
409
405
  ch = this.stream.peekChar(npeek);
410
406
  if (ch >= _0 && ch <= _9) {
411
407
  this.stream.advance(npeek + 1);
412
- this.stream.advanceWhileChar(function (ch) {
408
+ this.stream.advanceWhileChar((ch) => {
413
409
  return ch >= _0 && ch <= _9 || npeek === 0 && ch === _DOT;
414
410
  });
415
411
  return true;
416
412
  }
417
413
  return false;
418
- };
419
- Scanner.prototype._newline = function (result) {
420
- var ch = this.stream.peekChar();
414
+ }
415
+ _newline(result) {
416
+ const ch = this.stream.peekChar();
421
417
  switch (ch) {
422
418
  case _CAR:
423
419
  case _LFD:
@@ -430,13 +426,13 @@
430
426
  return true;
431
427
  }
432
428
  return false;
433
- };
434
- Scanner.prototype._escape = function (result, includeNewLines) {
435
- var ch = this.stream.peekChar();
429
+ }
430
+ _escape(result, includeNewLines) {
431
+ let ch = this.stream.peekChar();
436
432
  if (ch === _BSL) {
437
433
  this.stream.advance(1);
438
434
  ch = this.stream.peekChar();
439
- var hexNumCount = 0;
435
+ let hexNumCount = 0;
440
436
  while (hexNumCount < 6 && (ch >= _0 && ch <= _9 || ch >= _a && ch <= _f || ch >= _A && ch <= _F)) {
441
437
  this.stream.advance(1);
442
438
  ch = this.stream.peekChar();
@@ -444,7 +440,7 @@
444
440
  }
445
441
  if (hexNumCount > 0) {
446
442
  try {
447
- var hexVal = parseInt(this.stream.substring(this.stream.pos() - hexNumCount), 16);
443
+ const hexVal = parseInt(this.stream.substring(this.stream.pos() - hexNumCount), 16);
448
444
  if (hexVal) {
449
445
  result.push(String.fromCharCode(hexVal));
450
446
  }
@@ -471,20 +467,20 @@
471
467
  }
472
468
  }
473
469
  return false;
474
- };
475
- Scanner.prototype._stringChar = function (closeQuote, result) {
470
+ }
471
+ _stringChar(closeQuote, result) {
476
472
  // not closeQuote, not backslash, not newline
477
- var ch = this.stream.peekChar();
473
+ const ch = this.stream.peekChar();
478
474
  if (ch !== 0 && ch !== closeQuote && ch !== _BSL && ch !== _CAR && ch !== _LFD && ch !== _NWL) {
479
475
  this.stream.advance(1);
480
476
  result.push(String.fromCharCode(ch));
481
477
  return true;
482
478
  }
483
479
  return false;
484
- };
485
- Scanner.prototype._string = function (result) {
480
+ }
481
+ _string(result) {
486
482
  if (this.stream.peekChar() === _SQO || this.stream.peekChar() === _DQO) {
487
- var closeQuote = this.stream.nextChar();
483
+ const closeQuote = this.stream.nextChar();
488
484
  result.push(String.fromCharCode(closeQuote));
489
485
  while (this._stringChar(closeQuote, result) || this._escape(result, true)) {
490
486
  // loop
@@ -499,40 +495,40 @@
499
495
  }
500
496
  }
501
497
  return null;
502
- };
503
- Scanner.prototype._unquotedChar = function (result) {
498
+ }
499
+ _unquotedChar(result) {
504
500
  // not closeQuote, not backslash, not newline
505
- var ch = this.stream.peekChar();
501
+ const ch = this.stream.peekChar();
506
502
  if (ch !== 0 && ch !== _BSL && ch !== _SQO && ch !== _DQO && ch !== _LPA && ch !== _RPA && ch !== _WSP && ch !== _TAB && ch !== _NWL && ch !== _LFD && ch !== _CAR) {
507
503
  this.stream.advance(1);
508
504
  result.push(String.fromCharCode(ch));
509
505
  return true;
510
506
  }
511
507
  return false;
512
- };
513
- Scanner.prototype._unquotedString = function (result) {
514
- var hasContent = false;
508
+ }
509
+ _unquotedString(result) {
510
+ let hasContent = false;
515
511
  while (this._unquotedChar(result) || this._escape(result)) {
516
512
  hasContent = true;
517
513
  }
518
514
  return hasContent;
519
- };
520
- Scanner.prototype._whitespace = function () {
521
- var n = this.stream.advanceWhileChar(function (ch) {
515
+ }
516
+ _whitespace() {
517
+ const n = this.stream.advanceWhileChar((ch) => {
522
518
  return ch === _WSP || ch === _TAB || ch === _NWL || ch === _LFD || ch === _CAR;
523
519
  });
524
520
  return n > 0;
525
- };
526
- Scanner.prototype._name = function (result) {
527
- var matched = false;
521
+ }
522
+ _name(result) {
523
+ let matched = false;
528
524
  while (this._identChar(result) || this._escape(result)) {
529
525
  matched = true;
530
526
  }
531
527
  return matched;
532
- };
533
- Scanner.prototype.ident = function (result) {
534
- var pos = this.stream.pos();
535
- var hasMinus = this._minus(result);
528
+ }
529
+ ident(result) {
530
+ const pos = this.stream.pos();
531
+ const hasMinus = this._minus(result);
536
532
  if (hasMinus) {
537
533
  if (this._minus(result) /* -- */ || this._identFirstChar(result) || this._escape(result)) {
538
534
  while (this._identChar(result) || this._escape(result)) {
@@ -549,9 +545,9 @@
549
545
  }
550
546
  this.stream.goBackTo(pos);
551
547
  return false;
552
- };
553
- Scanner.prototype._identFirstChar = function (result) {
554
- var ch = this.stream.peekChar();
548
+ }
549
+ _identFirstChar(result) {
550
+ const ch = this.stream.peekChar();
555
551
  if (ch === _USC || // _
556
552
  ch >= _a && ch <= _z || // a-z
557
553
  ch >= _A && ch <= _Z || // A-Z
@@ -561,18 +557,18 @@
561
557
  return true;
562
558
  }
563
559
  return false;
564
- };
565
- Scanner.prototype._minus = function (result) {
566
- var ch = this.stream.peekChar();
560
+ }
561
+ _minus(result) {
562
+ const ch = this.stream.peekChar();
567
563
  if (ch === _MIN) {
568
564
  this.stream.advance(1);
569
565
  result.push(String.fromCharCode(ch));
570
566
  return true;
571
567
  }
572
568
  return false;
573
- };
574
- Scanner.prototype._identChar = function (result) {
575
- var ch = this.stream.peekChar();
569
+ }
570
+ _identChar(result) {
571
+ const ch = this.stream.peekChar();
576
572
  if (ch === _USC || // _
577
573
  ch === _MIN || // -
578
574
  ch >= _a && ch <= _z || // a-z
@@ -584,16 +580,16 @@
584
580
  return true;
585
581
  }
586
582
  return false;
587
- };
588
- Scanner.prototype._unicodeRange = function () {
583
+ }
584
+ _unicodeRange() {
589
585
  // follow https://www.w3.org/TR/CSS21/syndata.html#tokenization and https://www.w3.org/TR/css-syntax-3/#urange-syntax
590
586
  // assume u has already been parsed
591
587
  if (this.stream.advanceIfChar(_PLS)) {
592
- var isHexDigit = function (ch) { return (ch >= _0 && ch <= _9 || ch >= _a && ch <= _f || ch >= _A && ch <= _F); };
593
- var codePoints = this.stream.advanceWhileChar(isHexDigit) + this.stream.advanceWhileChar(function (ch) { return ch === _QSM; });
588
+ const isHexDigit = (ch) => (ch >= _0 && ch <= _9 || ch >= _a && ch <= _f || ch >= _A && ch <= _F);
589
+ const codePoints = this.stream.advanceWhileChar(isHexDigit) + this.stream.advanceWhileChar(ch => ch === _QSM);
594
590
  if (codePoints >= 1 && codePoints <= 6) {
595
591
  if (this.stream.advanceIfChar(_MIN)) {
596
- var digits = this.stream.advanceWhileChar(isHexDigit);
592
+ const digits = this.stream.advanceWhileChar(isHexDigit);
597
593
  if (digits >= 1 && digits <= 6) {
598
594
  return true;
599
595
  }
@@ -604,8 +600,7 @@
604
600
  }
605
601
  }
606
602
  return false;
607
- };
608
- return Scanner;
609
- }());
603
+ }
604
+ }
610
605
  exports.Scanner = Scanner;
611
606
  });