@tbela99/css-parser 1.4.11 → 1.6.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 (80) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +18 -11
  3. package/dist/index-umd-web.js +6558 -5310
  4. package/dist/index.cjs +6576 -5313
  5. package/dist/index.d.ts +805 -279
  6. package/dist/lib/ast/clone.js +13 -8
  7. package/dist/lib/ast/expand.js +65 -15
  8. package/dist/lib/ast/features/calc.js +19 -56
  9. package/dist/lib/ast/features/if.js +28 -4
  10. package/dist/lib/ast/features/inlinecssvariables.js +6 -5
  11. package/dist/lib/ast/features/prefix.js +52 -73
  12. package/dist/lib/ast/features/shorthand.js +11 -6
  13. package/dist/lib/ast/features/transform.js +6 -3
  14. package/dist/lib/ast/find.js +7 -5
  15. package/dist/lib/ast/math/expression.js +190 -32
  16. package/dist/lib/ast/minify.js +117 -49
  17. package/dist/lib/ast/node.js +52 -0
  18. package/dist/lib/ast/transform/compute.js +63 -4
  19. package/dist/lib/ast/transform/minify.js +6 -6
  20. package/dist/lib/ast/transform/perspective.js +1 -1
  21. package/dist/lib/ast/transform/rotate.js +1 -1
  22. package/dist/lib/ast/transform/scale.js +1 -1
  23. package/dist/lib/ast/transform/skew.js +1 -1
  24. package/dist/lib/ast/transform/translate.js +1 -1
  25. package/dist/lib/ast/transform/utils.js +46 -18
  26. package/dist/lib/ast/types.js +1 -1
  27. package/dist/lib/ast/walk.js +55 -11
  28. package/dist/lib/fs/resolve.js +68 -27
  29. package/dist/lib/parser/declaration/list.js +22 -7
  30. package/dist/lib/parser/declaration/map.js +40 -13
  31. package/dist/lib/parser/declaration/set.js +3 -1
  32. package/dist/lib/parser/linesmap.js +2 -12
  33. package/dist/lib/parser/parse.js +843 -912
  34. package/dist/lib/parser/source.js +16 -2
  35. package/dist/lib/parser/tokenize.js +1489 -725
  36. package/dist/lib/parser/utils/at-rule-container.js +29 -196
  37. package/dist/lib/parser/utils/at-rule-generic.js +6 -7
  38. package/dist/lib/parser/utils/at-rule-import.js +17 -13
  39. package/dist/lib/parser/utils/at-rule-media.js +36 -19
  40. package/dist/lib/parser/utils/at-rule-support.js +19 -9
  41. package/dist/lib/parser/utils/at-rule-when-else.js +11 -38
  42. package/dist/lib/parser/utils/at-rule.js +0 -18
  43. package/dist/lib/parser/utils/declaration.js +30 -95
  44. package/dist/lib/parser/utils/hash.js +4 -4
  45. package/dist/lib/parser/utils/selector.js +164 -141
  46. package/dist/lib/parser/utils/text.js +4 -2
  47. package/dist/lib/renderer/render.js +230 -125
  48. package/dist/lib/renderer/sourcemap/lib/codec.js +78 -0
  49. package/dist/lib/renderer/sourcemap/sourcemap.js +187 -34
  50. package/dist/lib/syntax/color/a98rgb.js +14 -4
  51. package/dist/lib/syntax/color/cmyk.js +10 -18
  52. package/dist/lib/syntax/color/color-mix.js +21 -34
  53. package/dist/lib/syntax/color/color.js +32 -49
  54. package/dist/lib/syntax/color/hsl.js +15 -15
  55. package/dist/lib/syntax/color/hwb.js +18 -17
  56. package/dist/lib/syntax/color/lab.js +17 -17
  57. package/dist/lib/syntax/color/lch.js +13 -13
  58. package/dist/lib/syntax/color/oklab.js +10 -11
  59. package/dist/lib/syntax/color/oklch.js +15 -18
  60. package/dist/lib/syntax/color/p3.js +18 -12
  61. package/dist/lib/syntax/color/prophotorgb.js +26 -28
  62. package/dist/lib/syntax/color/rec2020.js +8 -4
  63. package/dist/lib/syntax/color/relative-color.js +26 -10
  64. package/dist/lib/syntax/color/srgb.js +5 -4
  65. package/dist/lib/syntax/color/utils/distance.js +1 -1
  66. package/dist/lib/syntax/color/xyz.js +2 -2
  67. package/dist/lib/syntax/color/xyzd50.js +2 -2
  68. package/dist/lib/syntax/constants.js +12 -2
  69. package/dist/lib/syntax/syntax.js +45 -258
  70. package/dist/lib/validation/config.json.js +3 -0
  71. package/dist/lib/validation/match.js +110 -27
  72. package/dist/node.js +55 -33
  73. package/dist/types.d.ts +5 -1
  74. package/dist/types.js +4 -0
  75. package/dist/utils/sync.d.ts +16 -0
  76. package/dist/utils/sync.js +73 -0
  77. package/dist/web.js +37 -30
  78. package/package.json +1 -1
  79. package/dist/lib/renderer/sourcemap/lib/encode.js +0 -37
  80. package/llms.txt +0 -73
@@ -1,12 +1,13 @@
1
1
  import { EnumToken, EnumAstNodeStatus } from '../../ast/types.js';
2
2
  import { renderValue } from '../../renderer/render.js';
3
- import { LOC, ERRORS, STATE, TOKENS, pseudoElements, tokensfuncDefMap, combinators, PARENT } from '../../syntax/constants.js';
3
+ import { LOCEND, LOCSTA, LOCSRCID, ERRORS, STATE, TOKENS, pseudoElements, combinators, tokensfuncDefMap, PARENT } from '../../syntax/constants.js';
4
4
  import { isHash } from '../../syntax/syntax.js';
5
5
  import { getParsedSyntax, getSyntaxRule, getSyntaxConfig } from '../../validation/config.js';
6
6
  import { matchAllSyntaxes, createValidationContext, trimArray, matchSelectorSyntax } from '../../validation/match.js';
7
7
  import { ValidationSyntaxGroupEnum, ValidationTokenEnum } from '../../validation/parser/typedef.js';
8
8
  import { splitTokenList } from '../../validation/utils/list.js';
9
9
  import { trimWhiteSpace } from '../parse.js';
10
+ import { equalsIgnoreCase } from './text.js';
10
11
 
11
12
  /**
12
13
  * parse selector
@@ -25,7 +26,9 @@ function parseSelector(tokens, context, options, errors) {
25
26
  filtered[0] = {
26
27
  typ: EnumToken.PercentageTokenType,
27
28
  val: 0,
28
- [LOC]: filtered[0][LOC],
29
+ [LOCSRCID]: filtered[0][LOCSRCID],
30
+ [LOCSTA]: filtered[0][LOCSTA],
31
+ [LOCEND]: filtered[0][LOCEND],
29
32
  };
30
33
  }
31
34
  else if (filtered[0].typ === EnumToken.PercentageTokenType &&
@@ -33,7 +36,9 @@ function parseSelector(tokens, context, options, errors) {
33
36
  filtered[0] = {
34
37
  typ: EnumToken.IdenTokenType,
35
38
  val: "to",
36
- [LOC]: filtered[0][LOC],
39
+ [LOCSRCID]: filtered[0][LOCSRCID],
40
+ [LOCSTA]: filtered[0][LOCSTA],
41
+ [LOCEND]: filtered[0][LOCEND],
37
42
  };
38
43
  }
39
44
  part.splice(0, part.length, ...filtered);
@@ -44,11 +49,13 @@ function parseSelector(tokens, context, options, errors) {
44
49
  if (acc.length > 0) {
45
50
  acc.push({ typ: EnumToken.CommaTokenType });
46
51
  }
47
- acc.push(...curr);
52
+ for (const c of curr) {
53
+ acc.push(c);
54
+ }
48
55
  return acc;
49
56
  }, []));
50
57
  return {
51
- typ: EnumToken.KeyFramesRuleNodeType,
58
+ typ: EnumToken.KeyframesRuleNodeType,
52
59
  sel: [
53
60
  ...splitTokenList(trimArray(tokens)).reduce((acc, curr) => {
54
61
  acc.add(curr.reduce((acc, curr) => acc + renderValue(curr, { minify: false }), ""));
@@ -56,10 +63,9 @@ function parseSelector(tokens, context, options, errors) {
56
63
  }, new Set()),
57
64
  ].join(),
58
65
  chi: [],
59
- [LOC]: {
60
- ...tokens[0][LOC],
61
- end: tokens[tokens.length - 1]?.[LOC]?.end ?? tokens[0]?.[LOC]?.end
62
- },
66
+ [LOCSRCID]: tokens[0]?.[LOCSRCID],
67
+ [LOCSTA]: tokens[0]?.[LOCSTA],
68
+ [LOCEND]: tokens[tokens.length - 1]?.[LOCEND],
63
69
  [TOKENS]: tokens.length === 0 ? null : tokens,
64
70
  [STATE]: result.success ? EnumAstNodeStatus.Validated : EnumAstNodeStatus.Invalid,
65
71
  [ERRORS]: result.errors,
@@ -109,7 +115,7 @@ function parseSelector(tokens, context, options, errors) {
109
115
  typ: EnumToken.PseudoElementTokenType,
110
116
  val: ":" + tokens[i + 1].val,
111
117
  });
112
- tokens[i][LOC].end = tokens[i + 1][LOC].end;
118
+ tokens[i][LOCEND] = tokens[i + 1][LOCEND];
113
119
  tokens.splice(i + 1, 1);
114
120
  continue;
115
121
  }
@@ -121,7 +127,7 @@ function parseSelector(tokens, context, options, errors) {
121
127
  : tokens[i + 1].typ,
122
128
  val,
123
129
  });
124
- tokens[i][LOC].end = tokens[i + 1][LOC].end;
130
+ tokens[i][LOCEND] = tokens[i + 1][LOCEND];
125
131
  tokens.splice(i + 1, 1);
126
132
  continue;
127
133
  }
@@ -133,7 +139,7 @@ function parseSelector(tokens, context, options, errors) {
133
139
  typ: EnumToken.PseudoClassTokenType,
134
140
  val: (pseudoElements.includes(val) ? "" : ":") + val,
135
141
  });
136
- tokens[i][LOC].end = tokens[i + 1][LOC].end;
142
+ tokens[i][LOCEND] = tokens[i + 1][LOCEND];
137
143
  tokens.splice(i + 1, 1);
138
144
  continue;
139
145
  }
@@ -145,22 +151,75 @@ function parseSelector(tokens, context, options, errors) {
145
151
  : EnumToken.FunctionTokenDefType,
146
152
  val,
147
153
  });
148
- tokens[i][LOC].end = tokens[i + 1][LOC].end;
154
+ tokens[i][LOCEND] = tokens[i + 1][LOCEND];
149
155
  tokens.splice(i + 1, 1);
150
156
  continue;
151
157
  }
152
158
  }
153
159
  if (tokens[i].typ == EnumToken.ColorTokenType) {
154
- // if (isIdent((tokens[i] as ColorToken).val)) {
155
- // Object.assign(tokens[i], {
156
- // typ: EnumToken.IdenTokenType,
157
- // });
158
- // } else
159
160
  if (isHash(tokens[i].val)) {
160
161
  Object.assign(tokens[i], {
161
162
  typ: EnumToken.HashTokenType,
162
163
  });
163
164
  }
165
+ else {
166
+ return {
167
+ typ: EnumToken.RuleNodeType,
168
+ sel: [
169
+ ...tokens
170
+ .reduce((acc, curr, index, array) => {
171
+ // if (curr.typ == EnumToken.CommentTokenType) {
172
+ // return acc;
173
+ // }
174
+ if (curr.typ == EnumToken.WhitespaceTokenType) {
175
+ if (trimWhiteSpace.includes(array[index - 1]?.typ) ||
176
+ trimWhiteSpace.includes(array[index + 1]?.typ) ||
177
+ combinators.includes(array[index - 1]?.val) ||
178
+ combinators.includes(array[index + 1]?.val)) {
179
+ return acc;
180
+ }
181
+ }
182
+ let t = renderValue(curr, { minify: false });
183
+ if (t == ",") {
184
+ acc.push([]);
185
+ }
186
+ else {
187
+ acc[acc.length - 1].push(t);
188
+ }
189
+ return acc;
190
+ }, [[]])
191
+ .reduce((acc, curr) => {
192
+ let i = 0;
193
+ for (; i < curr.length; i++) {
194
+ if (i + 1 < curr.length && curr[i] == "*") {
195
+ if (curr[i] == "*") {
196
+ let index = curr[i + 1] == " " ? 2 : 1;
197
+ if (![">", "~", "+"].includes(curr[index])) {
198
+ curr.splice(i, index);
199
+ }
200
+ }
201
+ }
202
+ }
203
+ acc.set(curr.join(""), curr);
204
+ return acc;
205
+ }, uniq)
206
+ .keys(),
207
+ ].join(","),
208
+ chi: [],
209
+ [LOCSRCID]: tokens[0][LOCSRCID],
210
+ [LOCSTA]: tokens[0][LOCSTA],
211
+ [LOCEND]: tokens[tokens.length - 1][LOCEND],
212
+ [TOKENS]: tokens,
213
+ [STATE]: EnumAstNodeStatus.Invalid,
214
+ [ERRORS]: [
215
+ {
216
+ action: "drop",
217
+ node: tokens[i],
218
+ message: "invalid hash id",
219
+ },
220
+ ],
221
+ };
222
+ }
164
223
  }
165
224
  }
166
225
  const result = matchSelectorSyntax(tokens, errors, options, nested === true);
@@ -177,10 +236,9 @@ function parseSelector(tokens, context, options, errors) {
177
236
  index = tokens.indexOf(stack.at(-1));
178
237
  // @ts-expect-error
179
238
  const { val, ...attr } = stack.at(-1);
180
- attr[LOC] = {
181
- ...stack.at(-1)[LOC],
182
- end: token[LOC].end,
183
- };
239
+ attr[LOCSRCID] = stack.at(-1)[LOCSRCID];
240
+ attr[LOCSTA] = stack.at(-1)[LOCSTA];
241
+ attr[LOCEND] = token[LOCEND];
184
242
  tokens.splice(i, 1);
185
243
  Object.assign(attr, {
186
244
  typ: EnumToken.AttrTokenType,
@@ -198,7 +256,7 @@ function parseSelector(tokens, context, options, errors) {
198
256
  if (stack.at(-1)?.typ == EnumToken.PseudoClassFunctionTokenDefType) {
199
257
  const func = stack.at(-1);
200
258
  index = tokens.indexOf(func);
201
- stack.at(-1)[LOC].end = token[LOC].end;
259
+ stack.at(-1)[LOCEND] = token[LOCEND];
202
260
  tokens.splice(i, 1);
203
261
  if (tokensfuncDefMap.has(func.typ)) {
204
262
  // @ts-expect-error
@@ -212,6 +270,86 @@ function parseSelector(tokens, context, options, errors) {
212
270
  func.val == ":nth-last-child" ||
213
271
  func.val == ":nth-of-type" ||
214
272
  func.val == ":nth-last-of-type") {
273
+ const list = [];
274
+ let index;
275
+ for (index = 0; index < func.chi.length; index++) {
276
+ if (func.chi[index].typ == EnumToken.CommentTokenType ||
277
+ func.chi[index].typ == EnumToken.WhitespaceTokenType) {
278
+ continue;
279
+ }
280
+ if (func.chi[index].typ == EnumToken.IdenTokenType &&
281
+ equalsIgnoreCase("of", func.chi[index].val)) {
282
+ index--;
283
+ break;
284
+ }
285
+ list.push(func.chi[index]);
286
+ }
287
+ if (list.length == 2) {
288
+ if (list[1].typ == EnumToken.NumberTokenType) {
289
+ if (list[1].val == 0) {
290
+ list.length = 1;
291
+ if (list[0].typ == EnumToken.DimensionTokenType &&
292
+ list[0].val == -2) {
293
+ list[0].val = 2;
294
+ }
295
+ }
296
+ else {
297
+ const sign = Math.sign(list[1].val);
298
+ // @ts-ignore
299
+ list[1].val *= sign;
300
+ list.splice(1, 0, {
301
+ typ: EnumToken.LiteralTokenType,
302
+ val: sign > 0 ? "+" : "-",
303
+ });
304
+ }
305
+ }
306
+ if (list.length == 3 &&
307
+ list[2].typ == EnumToken.NumberTokenType &&
308
+ list[0].typ == EnumToken.DimensionTokenType &&
309
+ (list[0].val == 2 ||
310
+ list[0].val == -2)) {
311
+ if (1 == list[2].val) {
312
+ list.splice(0, 3, {
313
+ typ: EnumToken.IdenTokenType,
314
+ val: "odd",
315
+ [LOCSRCID]: list[0][LOCSRCID],
316
+ [LOCSTA]: list[0][LOCSTA],
317
+ [LOCEND]: list[0][LOCEND],
318
+ });
319
+ }
320
+ else if (0 == list[2].val) {
321
+ list.splice(0, 3, {
322
+ typ: EnumToken.IdenTokenType,
323
+ val: "even",
324
+ [LOCSRCID]: list[0][LOCSRCID],
325
+ [LOCSTA]: list[0][LOCSTA],
326
+ [LOCEND]: list[0][LOCEND],
327
+ });
328
+ }
329
+ }
330
+ func.chi.splice(0, index, ...list);
331
+ }
332
+ if (list.length == 1) {
333
+ if (list[0].typ == EnumToken.IdenTokenType &&
334
+ equalsIgnoreCase("-n", list[0].val)) {
335
+ list[0].val = "n";
336
+ }
337
+ }
338
+ if (list.length == 3) {
339
+ if (list[0].typ == EnumToken.IdenTokenType &&
340
+ ("n" == list[0].val ||
341
+ "-n" == list[0].val ||
342
+ "+n" == list[0].val)) {
343
+ if (list[1].typ == EnumToken.NextSiblingCombinatorTokenType) {
344
+ if (list[2].typ == EnumToken.NumberTokenType &&
345
+ 0 == list[2].val) {
346
+ list[0].val = "n";
347
+ func.chi.splice(0, index, list[0]);
348
+ break;
349
+ }
350
+ }
351
+ }
352
+ }
215
353
  const token = func.chi.find((t) => t.typ != EnumToken.WhitespaceTokenType && t.typ != EnumToken.CommentTokenType);
216
354
  if (token?.typ == EnumToken.IdenTokenType || token?.typ == EnumToken.LiteralTokenType) {
217
355
  if (token.typ == EnumToken.IdenTokenType &&
@@ -225,83 +363,10 @@ function parseSelector(tokens, context, options, errors) {
225
363
  }
226
364
  }
227
365
  else {
228
- // if (!/\d+$/.test((token as IdentToken | LiteralToken).val)) {
229
- // let index = func.chi.indexOf(token);
230
- // let i: number = index + 1;
231
- // let sign: Token | null = null;
232
- // let num: NumberToken | null = null;
233
- // for (; i < func.chi.length; i++) {
234
- // if (
235
- // func.chi[i].typ == EnumToken.WhitespaceTokenType ||
236
- // func.chi[i].typ == EnumToken.CommentTokenType
237
- // ) {
238
- // continue;
239
- // }
240
- // if (func.chi[i].typ == EnumToken.NumberTokenType) {
241
- // num = func.chi[i] as NumberToken;
242
- // break;
243
- // } else {
244
- // sign = func.chi[i] as Token;
245
- // }
246
- // }
247
- // if (num != null) {
248
- // if (num.val === 0) {
249
- // func.chi.splice(index + 1, i - index);
250
- // if ((token as IdentToken | LiteralToken).val == "-n") {
251
- // (token as IdentToken).val = "n";
252
- // }
253
- // break;
254
- // }
255
- // if (sign == null) {
256
- // func.chi.splice(index + 1, i - index - 1);
257
- // if (Math.sign(num.val as number) === 1) {
258
- // func.chi.splice(index + 1, 0, {
259
- // typ: EnumToken.LiteralTokenType,
260
- // val: "+",
261
- // });
262
- // }
263
- // }
264
- // } else if ((token as IdentToken | LiteralToken).val == "-n") {
265
- // (token as IdentToken).val = "n";
266
- // }
267
- // break;
268
- // }
269
366
  const matches = /^(([+-]?[0-9]*)?n)?([+-]?[0-9]+)?$/.exec(token.val);
270
367
  if (matches != null) {
271
368
  const a1 = matches[2] === "" ? 1 : matches[2] === "-" ? -1 : +matches[2];
272
369
  const b1 = +matches[3];
273
- // if (a1 === 0) {
274
- // if (b1 === 1) {
275
- // let hasSelector: boolean = false;
276
- // let i: number = func.chi.indexOf(token);
277
- // let j: number = i + 1;
278
- // for (; j < func.chi.length; j++) {
279
- // if (
280
- // func.chi[j].typ == EnumToken.IdenTokenType &&
281
- // (func.chi[j] as IdentToken).val == "of"
282
- // ) {
283
- // hasSelector = true;
284
- // break;
285
- // }
286
- // }
287
- // if (hasSelector) {
288
- // Object.assign(token, {
289
- // typ: EnumToken.NumberTokenType,
290
- // val: b1,
291
- // });
292
- // } else {
293
- // // :first-child
294
- // tokens[tokens.indexOf(func)] = {
295
- // typ: EnumToken.PseudoClassTokenType,
296
- // val: ":first-child",
297
- // [LOC]: func[LOC],
298
- // };
299
- // }
300
- // break;
301
- // } else {
302
- // Object.assign(token, { typ: EnumToken.NumberTokenType, val: b1 });
303
- // }
304
- // } else
305
370
  if (b1 === 0) {
306
371
  Object.assign(token, Math.abs(a1) === 1
307
372
  ? {
@@ -314,17 +379,6 @@ function parseSelector(tokens, context, options, errors) {
314
379
  unit: "n",
315
380
  });
316
381
  }
317
- // else if (Math.abs(a1) === 2) {
318
- // if (b1 === 0) {
319
- // Object.assign(token, {
320
- // typ: EnumToken.DimensionTokenType,
321
- // val: a1,
322
- // unit: "n",
323
- // });
324
- // } else if (Math.abs(b1) === 1) {
325
- // Object.assign(token, { typ: EnumToken.IdenTokenType, val: "odd" });
326
- // }
327
- // }
328
382
  }
329
383
  }
330
384
  }
@@ -343,36 +397,6 @@ function parseSelector(tokens, context, options, errors) {
343
397
  }
344
398
  }
345
399
  if (num != null) {
346
- // if ((token as DimensionToken).val === 0) {
347
- // if (num.val === 0) {
348
- // func.chi.splice(0, i);
349
- // } else if (num.val === 1) {
350
- // let hasSelector: boolean = false;
351
- // let j: number = i + 1;
352
- // for (; j < func.chi.length; j++) {
353
- // if (
354
- // func.chi[j].typ == EnumToken.IdenTokenType &&
355
- // (func.chi[j] as IdentToken).val == "of"
356
- // ) {
357
- // hasSelector = true;
358
- // break;
359
- // }
360
- // }
361
- // if (hasSelector) {
362
- // func.chi.splice(0, i);
363
- // } else {
364
- // tokens[tokens.indexOf(func)] = {
365
- // typ: EnumToken.PseudoClassTokenType,
366
- // val: ":first-child",
367
- // [LOC]: func[LOC],
368
- // };
369
- // }
370
- // break;
371
- // } else {
372
- // func.chi.splice(0, i);
373
- // }
374
- // break;
375
- // } else
376
400
  if (num.val === 0) {
377
401
  func.chi.splice(index + 1, i - index);
378
402
  if (token.val < 0) {
@@ -461,10 +485,9 @@ function parseSelector(tokens, context, options, errors) {
461
485
  .keys(),
462
486
  ].join(","),
463
487
  chi: [],
464
- [LOC]: {
465
- ...tokens[0][LOC],
466
- end: tokens[tokens.length - 1][LOC].end,
467
- },
488
+ [LOCSRCID]: tokens[0][LOCSRCID],
489
+ [LOCSTA]: tokens[0][LOCSTA],
490
+ [LOCEND]: tokens[tokens.length - 1][LOCEND],
468
491
  [TOKENS]: tokens,
469
492
  [STATE]: result.success && allowed
470
493
  ? EnumAstNodeStatus.Validated
@@ -7,9 +7,11 @@ function camelize(value) {
7
7
  function equalsIgnoreCase(a, b) {
8
8
  if (a.length !== b.length)
9
9
  return false;
10
+ let ca;
11
+ let cb;
10
12
  for (let i = 0; i < a.length; i++) {
11
- let ca = a.charCodeAt(i);
12
- let cb = b.charCodeAt(i);
13
+ ca = a.charCodeAt(i);
14
+ cb = b.charCodeAt(i);
13
15
  // Normalize A-Z to a-z
14
16
  if (ca >= 65 && ca <= 90)
15
17
  ca += 32;