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,18 +1,3 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
1
  (function (factory) {
17
2
  if (typeof module === "object" && typeof module.exports === "object") {
18
3
  var v = factory(require, exports);
@@ -29,28 +14,27 @@ var __extends = (this && this.__extends) || (function () {
29
14
  'use strict';
30
15
  Object.defineProperty(exports, "__esModule", { value: true });
31
16
  exports.selectorToElement = exports.SelectorPrinting = exports.toElement = exports.LabelElement = exports.RootElement = exports.Element = void 0;
32
- var nodes = require("../parser/cssNodes");
33
- var cssScanner_1 = require("../parser/cssScanner");
34
- var nls = require("vscode-nls");
35
- var localize = nls.loadMessageBundle();
36
- var Element = /** @class */ (function () {
37
- function Element() {
17
+ const nodes = require("../parser/cssNodes");
18
+ const cssScanner_1 = require("../parser/cssScanner");
19
+ const nls = require("vscode-nls");
20
+ const localize = nls.loadMessageBundle();
21
+ class Element {
22
+ constructor() {
38
23
  this.parent = null;
39
24
  this.children = null;
40
25
  this.attributes = null;
41
26
  }
42
- Element.prototype.findAttribute = function (name) {
27
+ findAttribute(name) {
43
28
  if (this.attributes) {
44
- for (var _i = 0, _a = this.attributes; _i < _a.length; _i++) {
45
- var attribute = _a[_i];
29
+ for (const attribute of this.attributes) {
46
30
  if (attribute.name === name) {
47
31
  return attribute.value;
48
32
  }
49
33
  }
50
34
  }
51
35
  return null;
52
- };
53
- Element.prototype.addChild = function (child) {
36
+ }
37
+ addChild(child) {
54
38
  if (child instanceof Element) {
55
39
  child.parent = this;
56
40
  }
@@ -58,103 +42,91 @@ var __extends = (this && this.__extends) || (function () {
58
42
  this.children = [];
59
43
  }
60
44
  this.children.push(child);
61
- };
62
- Element.prototype.append = function (text) {
45
+ }
46
+ append(text) {
63
47
  if (this.attributes) {
64
- var last = this.attributes[this.attributes.length - 1];
48
+ const last = this.attributes[this.attributes.length - 1];
65
49
  last.value = last.value + text;
66
50
  }
67
- };
68
- Element.prototype.prepend = function (text) {
51
+ }
52
+ prepend(text) {
69
53
  if (this.attributes) {
70
- var first = this.attributes[0];
54
+ const first = this.attributes[0];
71
55
  first.value = text + first.value;
72
56
  }
73
- };
74
- Element.prototype.findRoot = function () {
75
- var curr = this;
57
+ }
58
+ findRoot() {
59
+ let curr = this;
76
60
  while (curr.parent && !(curr.parent instanceof RootElement)) {
77
61
  curr = curr.parent;
78
62
  }
79
63
  return curr;
80
- };
81
- Element.prototype.removeChild = function (child) {
64
+ }
65
+ removeChild(child) {
82
66
  if (this.children) {
83
- var index = this.children.indexOf(child);
67
+ const index = this.children.indexOf(child);
84
68
  if (index !== -1) {
85
69
  this.children.splice(index, 1);
86
70
  return true;
87
71
  }
88
72
  }
89
73
  return false;
90
- };
91
- Element.prototype.addAttr = function (name, value) {
74
+ }
75
+ addAttr(name, value) {
92
76
  if (!this.attributes) {
93
77
  this.attributes = [];
94
78
  }
95
- for (var _i = 0, _a = this.attributes; _i < _a.length; _i++) {
96
- var attribute = _a[_i];
79
+ for (const attribute of this.attributes) {
97
80
  if (attribute.name === name) {
98
81
  attribute.value += ' ' + value;
99
82
  return;
100
83
  }
101
84
  }
102
- this.attributes.push({ name: name, value: value });
103
- };
104
- Element.prototype.clone = function (cloneChildren) {
105
- if (cloneChildren === void 0) { cloneChildren = true; }
106
- var elem = new Element();
85
+ this.attributes.push({ name, value });
86
+ }
87
+ clone(cloneChildren = true) {
88
+ const elem = new Element();
107
89
  if (this.attributes) {
108
90
  elem.attributes = [];
109
- for (var _i = 0, _a = this.attributes; _i < _a.length; _i++) {
110
- var attribute = _a[_i];
91
+ for (const attribute of this.attributes) {
111
92
  elem.addAttr(attribute.name, attribute.value);
112
93
  }
113
94
  }
114
95
  if (cloneChildren && this.children) {
115
96
  elem.children = [];
116
- for (var index = 0; index < this.children.length; index++) {
97
+ for (let index = 0; index < this.children.length; index++) {
117
98
  elem.addChild(this.children[index].clone());
118
99
  }
119
100
  }
120
101
  return elem;
121
- };
122
- Element.prototype.cloneWithParent = function () {
123
- var clone = this.clone(false);
102
+ }
103
+ cloneWithParent() {
104
+ const clone = this.clone(false);
124
105
  if (this.parent && !(this.parent instanceof RootElement)) {
125
- var parentClone = this.parent.cloneWithParent();
106
+ const parentClone = this.parent.cloneWithParent();
126
107
  parentClone.addChild(clone);
127
108
  }
128
109
  return clone;
129
- };
130
- return Element;
131
- }());
132
- exports.Element = Element;
133
- var RootElement = /** @class */ (function (_super) {
134
- __extends(RootElement, _super);
135
- function RootElement() {
136
- return _super !== null && _super.apply(this, arguments) || this;
137
110
  }
138
- return RootElement;
139
- }(Element));
111
+ }
112
+ exports.Element = Element;
113
+ class RootElement extends Element {
114
+ }
140
115
  exports.RootElement = RootElement;
141
- var LabelElement = /** @class */ (function (_super) {
142
- __extends(LabelElement, _super);
143
- function LabelElement(label) {
144
- var _this = _super.call(this) || this;
145
- _this.addAttr('name', label);
146
- return _this;
147
- }
148
- return LabelElement;
149
- }(Element));
116
+ class LabelElement extends Element {
117
+ constructor(label) {
118
+ super();
119
+ this.addAttr('name', label);
120
+ }
121
+ }
150
122
  exports.LabelElement = LabelElement;
151
- var MarkedStringPrinter = /** @class */ (function () {
152
- function MarkedStringPrinter(quote) {
123
+ class MarkedStringPrinter {
124
+ constructor(quote) {
153
125
  this.quote = quote;
154
126
  this.result = [];
155
127
  // empty
156
128
  }
157
- MarkedStringPrinter.prototype.print = function (element) {
129
+ print(element) {
158
130
  this.result = [];
159
131
  if (element instanceof RootElement) {
160
132
  if (element.children) {
@@ -164,31 +136,30 @@ var __extends = (this && this.__extends) || (function () {
164
136
  else {
165
137
  this.doPrint([element], 0);
166
138
  }
167
- var value = this.result.join('\n');
168
- return [{ language: 'html', value: value }];
169
- };
170
- MarkedStringPrinter.prototype.doPrint = function (elements, indent) {
171
- for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
172
- var element = elements_1[_i];
139
+ const value = this.result.join('\n');
140
+ return [{ language: 'html', value }];
141
+ }
142
+ doPrint(elements, indent) {
143
+ for (const element of elements) {
173
144
  this.doPrintElement(element, indent);
174
145
  if (element.children) {
175
146
  this.doPrint(element.children, indent + 1);
176
147
  }
177
148
  }
178
- };
179
- MarkedStringPrinter.prototype.writeLine = function (level, content) {
180
- var indent = new Array(level + 1).join(' ');
149
+ }
150
+ writeLine(level, content) {
151
+ const indent = new Array(level + 1).join(' ');
181
152
  this.result.push(indent + content);
182
- };
183
- MarkedStringPrinter.prototype.doPrintElement = function (element, indent) {
184
- var name = element.findAttribute('name');
153
+ }
154
+ doPrintElement(element, indent) {
155
+ const name = element.findAttribute('name');
185
156
  // special case: a simple label
186
157
  if (element instanceof LabelElement || name === '\u2026') {
187
158
  this.writeLine(indent, name);
188
159
  return;
189
160
  }
190
161
  // the real deal
191
- var content = ['<'];
162
+ const content = ['<'];
192
163
  // element name
193
164
  if (name) {
194
165
  content.push(name);
@@ -198,12 +169,11 @@ var __extends = (this && this.__extends) || (function () {
198
169
  }
199
170
  // attributes
200
171
  if (element.attributes) {
201
- for (var _i = 0, _a = element.attributes; _i < _a.length; _i++) {
202
- var attr = _a[_i];
172
+ for (const attr of element.attributes) {
203
173
  if (attr.name !== 'name') {
204
174
  content.push(' ');
205
175
  content.push(attr.name);
206
- var value = attr.value;
176
+ const value = attr.value;
207
177
  if (value) {
208
178
  content.push('=');
209
179
  content.push(quotes.ensure(value, this.quote));
@@ -213,9 +183,8 @@ var __extends = (this && this.__extends) || (function () {
213
183
  }
214
184
  content.push('>');
215
185
  this.writeLine(indent, content.join(''));
216
- };
217
- return MarkedStringPrinter;
218
- }());
186
+ }
187
+ }
219
188
  var quotes;
220
189
  (function (quotes) {
221
190
  function ensure(value, which) {
@@ -223,7 +192,7 @@ var __extends = (this && this.__extends) || (function () {
223
192
  }
224
193
  quotes.ensure = ensure;
225
194
  function remove(value) {
226
- var match = value.match(/^['"](.*)["']$/);
195
+ const match = value.match(/^['"](.*)["']$/);
227
196
  if (match) {
228
197
  return match[1];
229
198
  }
@@ -231,8 +200,8 @@ var __extends = (this && this.__extends) || (function () {
231
200
  }
232
201
  quotes.remove = remove;
233
202
  })(quotes || (quotes = {}));
234
- var Specificity = /** @class */ (function () {
235
- function Specificity() {
203
+ class Specificity {
204
+ constructor() {
236
205
  /** Count of identifiers (e.g., `#app`) */
237
206
  this.id = 0;
238
207
  /** Count of attributes (`[type="number"]`), classes (`.container-fluid`), and pseudo-classes (`:hover`) */
@@ -240,16 +209,14 @@ var __extends = (this && this.__extends) || (function () {
240
209
  /** Count of tag names (`div`), and pseudo-elements (`::before`) */
241
210
  this.tag = 0;
242
211
  }
243
- return Specificity;
244
- }());
212
+ }
245
213
  function toElement(node, parentElement) {
246
- var result = new Element();
247
- for (var _i = 0, _a = node.getChildren(); _i < _a.length; _i++) {
248
- var child = _a[_i];
214
+ let result = new Element();
215
+ for (const child of node.getChildren()) {
249
216
  switch (child.type) {
250
217
  case nodes.NodeType.SelectorCombinator:
251
218
  if (parentElement) {
252
- var segments = child.getText().split('&');
219
+ const segments = child.getText().split('&');
253
220
  if (segments.length === 1) {
254
221
  // should not happen
255
222
  result.addAttr('name', segments[0]);
@@ -257,12 +224,12 @@ var __extends = (this && this.__extends) || (function () {
257
224
  }
258
225
  result = parentElement.cloneWithParent();
259
226
  if (segments[0]) {
260
- var root = result.findRoot();
227
+ const root = result.findRoot();
261
228
  root.prepend(segments[0]);
262
229
  }
263
- for (var i = 1; i < segments.length; i++) {
230
+ for (let i = 1; i < segments.length; i++) {
264
231
  if (i > 1) {
265
- var clone = parentElement.cloneWithParent();
232
+ const clone = parentElement.cloneWithParent();
266
233
  result.addChild(clone.findRoot());
267
234
  result = clone;
268
235
  }
@@ -276,7 +243,7 @@ var __extends = (this && this.__extends) || (function () {
276
243
  }
277
244
  // fall through
278
245
  case nodes.NodeType.ElementNameSelector:
279
- var text = child.getText();
246
+ const text = child.getText();
280
247
  result.addAttr('name', text === '*' ? 'element' : unescape(text));
281
248
  break;
282
249
  case nodes.NodeType.ClassSelector:
@@ -292,33 +259,33 @@ var __extends = (this && this.__extends) || (function () {
292
259
  result.addAttr(unescape(child.getText()), '');
293
260
  break;
294
261
  case nodes.NodeType.AttributeSelector:
295
- var selector = child;
296
- var identifier = selector.getIdentifier();
262
+ const selector = child;
263
+ const identifier = selector.getIdentifier();
297
264
  if (identifier) {
298
- var expression = selector.getValue();
299
- var operator = selector.getOperator();
300
- var value = void 0;
265
+ const expression = selector.getValue();
266
+ const operator = selector.getOperator();
267
+ let value;
301
268
  if (expression && operator) {
302
269
  switch (unescape(operator.getText())) {
303
270
  case '|=':
304
271
  // excatly or followed by -words
305
- value = "".concat(quotes.remove(unescape(expression.getText())), "-\u2026");
272
+ value = `${quotes.remove(unescape(expression.getText()))}-\u2026`;
306
273
  break;
307
274
  case '^=':
308
275
  // prefix
309
- value = "".concat(quotes.remove(unescape(expression.getText())), "\u2026");
276
+ value = `${quotes.remove(unescape(expression.getText()))}\u2026`;
310
277
  break;
311
278
  case '$=':
312
279
  // suffix
313
- value = "\u2026".concat(quotes.remove(unescape(expression.getText())));
280
+ value = `\u2026${quotes.remove(unescape(expression.getText()))}`;
314
281
  break;
315
282
  case '~=':
316
283
  // one of a list of words
317
- value = " \u2026 ".concat(quotes.remove(unescape(expression.getText())), " \u2026 ");
284
+ value = ` \u2026 ${quotes.remove(unescape(expression.getText()))} \u2026 `;
318
285
  break;
319
286
  case '*=':
320
287
  // substring
321
- value = "\u2026".concat(quotes.remove(unescape(expression.getText())), "\u2026");
288
+ value = `\u2026${quotes.remove(unescape(expression.getText()))}\u2026`;
322
289
  break;
323
290
  default:
324
291
  value = quotes.remove(unescape(expression.getText()));
@@ -334,49 +301,47 @@ var __extends = (this && this.__extends) || (function () {
334
301
  }
335
302
  exports.toElement = toElement;
336
303
  function unescape(content) {
337
- var scanner = new cssScanner_1.Scanner();
304
+ const scanner = new cssScanner_1.Scanner();
338
305
  scanner.setSource(content);
339
- var token = scanner.scanUnquotedString();
306
+ const token = scanner.scanUnquotedString();
340
307
  if (token) {
341
308
  return token.text;
342
309
  }
343
310
  return content;
344
311
  }
345
- var SelectorPrinting = /** @class */ (function () {
346
- function SelectorPrinting(cssDataManager) {
312
+ class SelectorPrinting {
313
+ constructor(cssDataManager) {
347
314
  this.cssDataManager = cssDataManager;
348
315
  }
349
- SelectorPrinting.prototype.selectorToMarkedString = function (node) {
350
- var root = selectorToElement(node);
316
+ selectorToMarkedString(node) {
317
+ const root = selectorToElement(node);
351
318
  if (root) {
352
- var markedStrings = new MarkedStringPrinter('"').print(root);
319
+ const markedStrings = new MarkedStringPrinter('"').print(root);
353
320
  markedStrings.push(this.selectorToSpecificityMarkedString(node));
354
321
  return markedStrings;
355
322
  }
356
323
  else {
357
324
  return [];
358
325
  }
359
- };
360
- SelectorPrinting.prototype.simpleSelectorToMarkedString = function (node) {
361
- var element = toElement(node);
362
- var markedStrings = new MarkedStringPrinter('"').print(element);
326
+ }
327
+ simpleSelectorToMarkedString(node) {
328
+ const element = toElement(node);
329
+ const markedStrings = new MarkedStringPrinter('"').print(element);
363
330
  markedStrings.push(this.selectorToSpecificityMarkedString(node));
364
331
  return markedStrings;
365
- };
366
- SelectorPrinting.prototype.isPseudoElementIdentifier = function (text) {
367
- var match = text.match(/^::?([\w-]+)/);
332
+ }
333
+ isPseudoElementIdentifier(text) {
334
+ const match = text.match(/^::?([\w-]+)/);
368
335
  if (!match) {
369
336
  return false;
370
337
  }
371
338
  return !!this.cssDataManager.getPseudoElement("::" + match[1]);
372
- };
373
- SelectorPrinting.prototype.selectorToSpecificityMarkedString = function (node) {
374
- var _this = this;
339
+ }
340
+ selectorToSpecificityMarkedString(node) {
375
341
  //https://www.w3.org/TR/selectors-3/#specificity
376
- var calculateScore = function (node) {
377
- var specificity = new Specificity();
378
- elementLoop: for (var _i = 0, _a = node.getChildren(); _i < _a.length; _i++) {
379
- var element = _a[_i];
342
+ const calculateScore = (node) => {
343
+ const specificity = new Specificity();
344
+ elementLoop: for (const element of node.getChildren()) {
380
345
  switch (element.type) {
381
346
  case nodes.NodeType.IdentifierSelector:
382
347
  specificity.id++;
@@ -393,8 +358,8 @@ var __extends = (this && this.__extends) || (function () {
393
358
  specificity.tag++;
394
359
  break;
395
360
  case nodes.NodeType.PseudoSelector:
396
- var text = element.getText();
397
- if (_this.isPseudoElementIdentifier(text)) {
361
+ const text = element.getText();
362
+ if (this.isPseudoElementIdentifier(text)) {
398
363
  specificity.tag++; // pseudo element
399
364
  continue elementLoop;
400
365
  }
@@ -404,19 +369,17 @@ var __extends = (this && this.__extends) || (function () {
404
369
  }
405
370
  // the most specific child selector
406
371
  if (text.match(/^:(not|has|is)/i) && element.getChildren().length > 0) {
407
- var mostSpecificListItem = new Specificity();
408
- for (var _b = 0, _c = element.getChildren(); _b < _c.length; _b++) {
409
- var containerElement = _c[_b];
410
- var list = void 0;
372
+ let mostSpecificListItem = new Specificity();
373
+ for (const containerElement of element.getChildren()) {
374
+ let list;
411
375
  if (containerElement.type === nodes.NodeType.Undefined) { // containerElement is a list of selectors
412
376
  list = containerElement.getChildren();
413
377
  }
414
378
  else { // containerElement is a selector
415
379
  list = [containerElement];
416
380
  }
417
- for (var _d = 0, _e = containerElement.getChildren(); _d < _e.length; _d++) {
418
- var childElement = _e[_d];
419
- var itemSpecificity = calculateScore(childElement);
381
+ for (const childElement of containerElement.getChildren()) {
382
+ const itemSpecificity = calculateScore(childElement);
420
383
  if (itemSpecificity.id > mostSpecificListItem.id) {
421
384
  mostSpecificListItem = itemSpecificity;
422
385
  continue;
@@ -446,7 +409,7 @@ var __extends = (this && this.__extends) || (function () {
446
409
  continue elementLoop;
447
410
  }
448
411
  if (element.getChildren().length > 0) {
449
- var itemSpecificity = calculateScore(element);
412
+ const itemSpecificity = calculateScore(element);
450
413
  specificity.id += itemSpecificity.id;
451
414
  specificity.attr += itemSpecificity.attr;
452
415
  specificity.tag += itemSpecificity.tag;
@@ -454,23 +417,22 @@ var __extends = (this && this.__extends) || (function () {
454
417
  }
455
418
  return specificity;
456
419
  };
457
- var specificity = calculateScore(node);
420
+ const specificity = calculateScore(node);
458
421
  ;
459
422
  return localize('specificity', "[Selector Specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity): ({0}, {1}, {2})", specificity.id, specificity.attr, specificity.tag);
460
- };
461
- return SelectorPrinting;
462
- }());
423
+ }
424
+ }
463
425
  exports.SelectorPrinting = SelectorPrinting;
464
- var SelectorElementBuilder = /** @class */ (function () {
465
- function SelectorElementBuilder(element) {
426
+ class SelectorElementBuilder {
427
+ constructor(element) {
466
428
  this.prev = null;
467
429
  this.element = element;
468
430
  }
469
- SelectorElementBuilder.prototype.processSelector = function (selector) {
470
- var parentElement = null;
431
+ processSelector(selector) {
432
+ let parentElement = null;
471
433
  if (!(this.element instanceof RootElement)) {
472
- if (selector.getChildren().some(function (c) { return c.hasChildren() && c.getChild(0).type === nodes.NodeType.SelectorCombinator; })) {
473
- var curr = this.element.findRoot();
434
+ if (selector.getChildren().some((c) => c.hasChildren() && c.getChild(0).type === nodes.NodeType.SelectorCombinator)) {
435
+ const curr = this.element.findRoot();
474
436
  if (curr.parent instanceof RootElement) {
475
437
  parentElement = this.element;
476
438
  this.element = curr.parent;
@@ -479,11 +441,10 @@ var __extends = (this && this.__extends) || (function () {
479
441
  }
480
442
  }
481
443
  }
482
- for (var _i = 0, _a = selector.getChildren(); _i < _a.length; _i++) {
483
- var selectorChild = _a[_i];
444
+ for (const selectorChild of selector.getChildren()) {
484
445
  if (selectorChild instanceof nodes.SimpleSelector) {
485
446
  if (this.prev instanceof nodes.SimpleSelector) {
486
- var labelElement = new LabelElement('\u2026');
447
+ const labelElement = new LabelElement('\u2026');
487
448
  this.element.addChild(labelElement);
488
449
  this.element = labelElement;
489
450
  }
@@ -493,8 +454,8 @@ var __extends = (this && this.__extends) || (function () {
493
454
  if (this.prev && this.prev.matches('~')) {
494
455
  this.element.addChild(new LabelElement('\u22EE'));
495
456
  }
496
- var thisElement = toElement(selectorChild, parentElement);
497
- var root = thisElement.findRoot();
457
+ const thisElement = toElement(selectorChild, parentElement);
458
+ const root = thisElement.findRoot();
498
459
  this.element.addChild(root);
499
460
  this.element = thisElement;
500
461
  }
@@ -506,9 +467,8 @@ var __extends = (this && this.__extends) || (function () {
506
467
  this.prev = selectorChild;
507
468
  }
508
469
  }
509
- };
510
- return SelectorElementBuilder;
511
- }());
470
+ }
471
+ }
512
472
  function isNewSelectorContext(node) {
513
473
  switch (node.type) {
514
474
  case nodes.NodeType.MixinDeclaration:
@@ -521,11 +481,11 @@ var __extends = (this && this.__extends) || (function () {
521
481
  if (node.matches('@at-root')) {
522
482
  return null;
523
483
  }
524
- var root = new RootElement();
525
- var parentRuleSets = [];
526
- var ruleSet = node.getParent();
484
+ const root = new RootElement();
485
+ const parentRuleSets = [];
486
+ const ruleSet = node.getParent();
527
487
  if (ruleSet instanceof nodes.RuleSet) {
528
- var parent = ruleSet.getParent(); // parent of the selector's ruleset
488
+ let parent = ruleSet.getParent(); // parent of the selector's ruleset
529
489
  while (parent && !isNewSelectorContext(parent)) {
530
490
  if (parent instanceof nodes.RuleSet) {
531
491
  if (parent.getSelectors().matches('@at-root')) {
@@ -536,9 +496,9 @@ var __extends = (this && this.__extends) || (function () {
536
496
  parent = parent.getParent();
537
497
  }
538
498
  }
539
- var builder = new SelectorElementBuilder(root);
540
- for (var i = parentRuleSets.length - 1; i >= 0; i--) {
541
- var selector = parentRuleSets[i].getSelectors().getChild(0);
499
+ const builder = new SelectorElementBuilder(root);
500
+ for (let i = parentRuleSets.length - 1; i >= 0; i--) {
501
+ const selector = parentRuleSets[i].getSelectors().getChild(0);
542
502
  if (selector) {
543
503
  builder.processSelector(selector);
544
504
  }
@@ -20,12 +20,12 @@
20
20
  * @returns the least x for which p(x) is true or array.length if no element fullfills the given function.
21
21
  */
22
22
  function findFirst(array, p) {
23
- var low = 0, high = array.length;
23
+ let low = 0, high = array.length;
24
24
  if (high === 0) {
25
25
  return 0; // no children
26
26
  }
27
27
  while (low < high) {
28
- var mid = Math.floor((low + high) / 2);
28
+ let mid = Math.floor((low + high) / 2);
29
29
  if (p(array[mid])) {
30
30
  high = mid;
31
31
  }
@@ -40,16 +40,10 @@
40
40
  return array.indexOf(item) !== -1;
41
41
  }
42
42
  exports.includes = includes;
43
- function union() {
44
- var arrays = [];
45
- for (var _i = 0; _i < arguments.length; _i++) {
46
- arrays[_i] = arguments[_i];
47
- }
48
- var result = [];
49
- for (var _a = 0, arrays_1 = arrays; _a < arrays_1.length; _a++) {
50
- var array = arrays_1[_a];
51
- for (var _b = 0, array_1 = array; _b < array_1.length; _b++) {
52
- var item = array_1[_b];
43
+ function union(...arrays) {
44
+ const result = [];
45
+ for (const array of arrays) {
46
+ for (const item of array) {
53
47
  if (!includes(result, item)) {
54
48
  result.push(item);
55
49
  }
@@ -15,7 +15,7 @@
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.isDefined = exports.values = void 0;
17
17
  function values(obj) {
18
- return Object.keys(obj).map(function (key) { return obj[key]; });
18
+ return Object.keys(obj).map(key => obj[key]);
19
19
  }
20
20
  exports.values = values;
21
21
  function isDefined(obj) {