@tbela99/css-parser 1.6.4 → 1.6.6

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.
@@ -475,6 +475,7 @@ function doParseSync(tokenizer, options = {}) {
475
475
  if (options.expandNestingRules) {
476
476
  options.nestingRules = false;
477
477
  }
478
+ options.minifyAST ??= options.minify;
478
479
  const startTime = performance.now();
479
480
  const errors = [];
480
481
  const stack = [];
@@ -505,7 +506,6 @@ function doParseSync(tokenizer, options = {}) {
505
506
  // let currentItemIndex: number;
506
507
  ast[LOCSRCID] = options.source.id;
507
508
  ast[LOCSTA] = 0;
508
- // let tokenizer: Tokenizer;
509
509
  while (!tokenizer.done()) {
510
510
  tokenizer.next();
511
511
  // item = (iter as Array<TokenizeResult>)[currentItemIndex];
@@ -854,7 +854,7 @@ function doParseSync(tokenizer, options = {}) {
854
854
  }
855
855
  }
856
856
  }
857
- if (options.minify) {
857
+ if (options.minifyAST) {
858
858
  if (ast.chi.length > 0) {
859
859
  let passes = options.pass ?? 1;
860
860
  while (passes--) {
@@ -1394,6 +1394,7 @@ async function doParse(iter, options = {}) {
1394
1394
  lenient: true,
1395
1395
  ...options,
1396
1396
  };
1397
+ options.minifyAST ??= options.minify;
1397
1398
  if (typeof options.validation !== "boolean") {
1398
1399
  options.validation = !!options.validation;
1399
1400
  }
@@ -1848,7 +1849,7 @@ async function doParse(iter, options = {}) {
1848
1849
  }
1849
1850
  }
1850
1851
  }
1851
- if (options.minify) {
1852
+ if (options.minifyAST) {
1852
1853
  if (ast.chi.length > 0) {
1853
1854
  let passes = options.pass ?? 1;
1854
1855
  while (passes--) {
@@ -4,6 +4,7 @@ import { isWhiteSpace, isNewLine, isDigit, isLetter, isIdentStart, isIdentCodepo
4
4
  import { SourceFile } from './source.js';
5
5
 
6
6
  const SymbolsMapTokens = Object.create(null);
7
+ const SymbolsMapTokensLower = Object.create(null);
7
8
  // Regex for escape sequence decoding - compile once, reuse many times
8
9
  const ESCAPE_SEQUENCE_REGEX = /\\((\n|\r|\f|\v|\u2028|\u2029|([0-9a-fA-F]{1,6})) ?)/gms;
9
10
  function decodeEscapeSequences(value) {
@@ -32,7 +33,9 @@ function decodeEscapeSequences(value) {
32
33
  }
33
34
  function assignTokenMap(entries, tokenType, suffix = "", lowercase = false) {
34
35
  for (const entry of entries) {
35
- SymbolsMapTokens[(lowercase ? entry.toLowerCase() : entry) + suffix] = tokenType;
36
+ const key = (lowercase ? entry.toLowerCase() : entry) + suffix;
37
+ SymbolsMapTokens[key] = tokenType;
38
+ SymbolsMapTokensLower[key.toLowerCase()] = tokenType;
36
39
  }
37
40
  }
38
41
  SymbolsMapTokens[""] = EnumToken.DelimTokenType;
@@ -132,20 +135,24 @@ var TokenMap;
132
135
  })(TokenMap || (TokenMap = {}));
133
136
  function getSymbolHint(parseInfo, start, end) {
134
137
  const len = end - start;
135
- const keysLength = SymbolsMapTokensKeys.length;
136
- // Early exit for impossible lengths
137
- if (len < 0)
138
+ if (len <= 0)
138
139
  return null;
140
+ const value = parseInfo.stream.slice(start, end);
141
+ // Direct lookup handles the hottest punctuation and keyword cases without
142
+ // scanning the entire symbol table on every token.
143
+ const match = SymbolsMapTokens[value] ?? SymbolsMapTokensLower[value.toLowerCase()];
144
+ if (match != null) {
145
+ return match;
146
+ }
147
+ const keysLength = SymbolsMapTokensKeys.length;
139
148
  for (let i = 0; i < keysLength; i++) {
140
149
  const key = SymbolsMapTokensKeys[i];
141
150
  if (key.length !== len)
142
151
  continue;
143
- // Match character by character
144
152
  let match = true;
145
153
  for (let j = 0; j < len; j++) {
146
154
  let ca = key.charCodeAt(j);
147
- let cb = parseInfo.stream.charCodeAt(start + j);
148
- // Normalize A-Z to a-z
155
+ let cb = value.charCodeAt(j);
149
156
  if (ca >= 65 && ca <= 90)
150
157
  ca += 32;
151
158
  if (cb >= 65 && cb <= 90)
@@ -163,32 +170,29 @@ function getSymbolHint(parseInfo, start, end) {
163
170
  }
164
171
  function searchArray(array, parseInfo, start, end) {
165
172
  const len = end - start;
166
- // Early exit for impossible lengths
167
- if (len < 0)
173
+ if (len <= 0)
168
174
  return null;
169
- // Use a simple linear search optimized with length pre-filtering
170
- let i = array.length;
171
- while (i--) {
172
- if (array[i].length !== len)
175
+ let match;
176
+ let item;
177
+ for (let i = 0; i < array.length; i++) {
178
+ item = array[i];
179
+ if (item.length !== len)
173
180
  continue;
174
- // Match character by character
175
- let match = true;
176
- const arrayItem = array[i];
181
+ match = true;
177
182
  for (let j = 0; j < len; j++) {
178
- let ca = arrayItem.charCodeAt(j);
179
- let cb = parseInfo.stream.charCodeAt(start + j);
180
- // Normalize A-Z to a-z
183
+ let ca = parseInfo.stream.charCodeAt(start + j);
184
+ let cb = item.charCodeAt(j);
181
185
  if (ca >= 65 && ca <= 90)
182
186
  ca += 32;
183
187
  if (cb >= 65 && cb <= 90)
184
188
  cb += 32;
185
- if (ca != cb) {
189
+ if (ca !== cb) {
186
190
  match = false;
187
191
  break;
188
192
  }
189
193
  }
190
194
  if (match) {
191
- return arrayItem;
195
+ return item;
192
196
  }
193
197
  }
194
198
  return null;
@@ -1126,23 +1130,6 @@ class Tokenizer {
1126
1130
  }
1127
1131
  return true;
1128
1132
  }
1129
- /**
1130
- *
1131
- * @param parseInfo
1132
- * @returns
1133
- */
1134
- // isPseudo(parseInfo: ParseInfo): boolean {
1135
- // let position: number = parseInfo.currentPosition - parseInfo.offset;
1136
- // let endPosition: number = parseInfo.currentPosition - parseInfo.offset;
1137
- // return (parseInfo.stream.charAt(position) == ":" &&
1138
- // parseInfo.stream.charAt(endPosition - 1) == "(" &&
1139
- // (parseInfo.stream.charAt(position + 1) == ":"
1140
- // ? this.isIdentToken(parseInfo, 2, -1)
1141
- // : this.isIdentToken(parseInfo, 1, -1))) ||
1142
- // parseInfo.stream.charAt(position + 1) == ":"
1143
- // ? this.isIdentToken(parseInfo, 2)
1144
- // : this.isIdentToken(parseInfo, 1);
1145
- // }
1146
1133
  /**
1147
1134
  *
1148
1135
  * @param parseInfo
@@ -1273,28 +1260,28 @@ class Tokenizer {
1273
1260
  // EOF
1274
1261
  switch (charCode) {
1275
1262
  case 61 /* TokenMap.EQUALS */:
1276
- if (parseInfo.position < parseInfo.currentPosition) {
1277
- return this.makeToken(parseInfo);
1278
- }
1263
+ // if (parseInfo.position < parseInfo.currentPosition) {
1264
+ // return this.makeToken(parseInfo);
1265
+ // }
1279
1266
  this.advance(parseInfo);
1280
1267
  return this.makeToken(parseInfo, EnumToken.DelimTokenType);
1281
1268
  // '+' or '-'
1282
1269
  case 43 /* TokenMap.PLUS */:
1283
- if (parseInfo.position < parseInfo.currentPosition) {
1284
- return this.makeToken(parseInfo);
1285
- }
1270
+ // if (parseInfo.position < parseInfo.currentPosition) {
1271
+ // return this.makeToken(parseInfo);
1272
+ // }
1286
1273
  this.advance(parseInfo);
1287
1274
  charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset);
1288
- if (isDigit(charCode)) {
1289
- tokensCount = this.consumeNumericToken(parseInfo);
1290
- if (tokensCount > 0) {
1291
- this.advance(parseInfo, tokensCount);
1292
- return this.makeToken(parseInfo, this.hint ?? EnumToken.NumberTokenType, {
1293
- slice: this.slice,
1294
- sign: "+",
1295
- });
1296
- }
1297
- }
1275
+ // if (isDigit(charCode)) {
1276
+ // tokensCount = this.consumeNumericToken(parseInfo);
1277
+ // if (tokensCount > 0) {
1278
+ // this.advance(parseInfo, tokensCount);
1279
+ // return this.makeToken(parseInfo, this.hint ?? EnumToken.NumberTokenType, {
1280
+ // slice: this.slice,
1281
+ // sign: "+",
1282
+ // });
1283
+ // }
1284
+ // }
1298
1285
  return this.makeToken(parseInfo, EnumToken.Plus);
1299
1286
  case 45 /* TokenMap.MINUS */:
1300
1287
  if (parseInfo.position == parseInfo.currentPosition) {
@@ -1304,15 +1291,17 @@ class Tokenizer {
1304
1291
  this.advance(parseInfo);
1305
1292
  return this.makeToken(parseInfo, EnumToken.Sub);
1306
1293
  }
1307
- if (charCode == 45 /* TokenMap.MINUS */ &&
1308
- (nextCharCode == 45 /* TokenMap.MINUS */ || isIdentStart(nextCharCode))) {
1309
- this.advance(parseInfo);
1310
- tokensCount = this.consumeIdentToken(parseInfo);
1311
- if (tokensCount > 0) {
1312
- this.advance(parseInfo, tokensCount);
1313
- return this.makeToken(parseInfo, EnumToken.IdenTokenType);
1314
- }
1315
- }
1294
+ // if (
1295
+ // charCode == TokenMap.MINUS &&
1296
+ // (nextCharCode == TokenMap.MINUS || isIdentStart(nextCharCode))
1297
+ // ) {
1298
+ // this.advance(parseInfo);
1299
+ // tokensCount = this.consumeIdentToken(parseInfo);
1300
+ // if (tokensCount > 0) {
1301
+ // this.advance(parseInfo, tokensCount);
1302
+ // return this.makeToken(parseInfo, EnumToken.IdenTokenType);
1303
+ // }
1304
+ // }
1316
1305
  }
1317
1306
  this.advance(parseInfo);
1318
1307
  break;
@@ -1365,28 +1354,28 @@ class Tokenizer {
1365
1354
  return this.makeToken(parseInfo, EnumToken.EndParensTokenType);
1366
1355
  // '['
1367
1356
  case 91 /* TokenMap.LEFT_BRACKETS */:
1368
- if (parseInfo.position < parseInfo.currentPosition) {
1369
- return this.makeToken(parseInfo);
1370
- }
1357
+ // if (parseInfo.position < parseInfo.currentPosition) {
1358
+ // return this.makeToken(parseInfo);
1359
+ // }
1371
1360
  this.advance(parseInfo);
1372
1361
  return this.makeToken(parseInfo, EnumToken.AttrStartTokenType);
1373
1362
  // ']'
1374
1363
  case 93 /* TokenMap.RIGHT_BRACKETS */:
1375
- if (parseInfo.position < parseInfo.currentPosition) {
1376
- return this.makeToken(parseInfo);
1377
- }
1364
+ // if (parseInfo.position < parseInfo.currentPosition) {
1365
+ // return this.makeToken(parseInfo);
1366
+ // }
1378
1367
  this.advance(parseInfo);
1379
1368
  return this.makeToken(parseInfo, EnumToken.AttrEndTokenType);
1380
1369
  case 59 /* TokenMap.SEMICOLON */:
1381
- if (parseInfo.position < parseInfo.currentPosition) {
1382
- return this.makeToken(parseInfo);
1383
- }
1370
+ // if (parseInfo.position < parseInfo.currentPosition) {
1371
+ // return this.makeToken(parseInfo);
1372
+ // }
1384
1373
  this.advance(parseInfo);
1385
1374
  return this.makeToken(parseInfo, EnumToken.SemiColonTokenType);
1386
1375
  case 58 /* TokenMap.COLON */:
1387
- if (parseInfo.position < parseInfo.currentPosition) {
1388
- return this.makeToken(parseInfo);
1389
- }
1376
+ // if (parseInfo.position < parseInfo.currentPosition) {
1377
+ // return this.makeToken(parseInfo);
1378
+ // }
1390
1379
  this.advance(parseInfo);
1391
1380
  if (this.peekCharCode(parseInfo) == 58 /* TokenMap.COLON */) {
1392
1381
  this.advance(parseInfo);
@@ -1418,15 +1407,15 @@ class Tokenizer {
1418
1407
  }
1419
1408
  return this.makeToken(parseInfo, EnumToken.WhitespaceTokenType);
1420
1409
  case 44 /* TokenMap.COMMA */:
1421
- if (parseInfo.position < parseInfo.currentPosition) {
1422
- return this.makeToken(parseInfo);
1423
- }
1410
+ // if (parseInfo.position < parseInfo.currentPosition) {
1411
+ // return this.makeToken(parseInfo);
1412
+ // }
1424
1413
  this.advance(parseInfo);
1425
1414
  return this.makeToken(parseInfo, EnumToken.CommaTokenType);
1426
1415
  case 36 /* TokenMap.DOLLAR */:
1427
- if (parseInfo.position < parseInfo.currentPosition) {
1428
- return this.makeToken(parseInfo);
1429
- }
1416
+ // if (parseInfo.position < parseInfo.currentPosition) {
1417
+ // return this.makeToken(parseInfo);
1418
+ // }
1430
1419
  if (this.match(parseInfo, "$=")) {
1431
1420
  this.advance(parseInfo, 2);
1432
1421
  return this.makeToken(parseInfo, EnumToken.EndMatchTokenType);
@@ -1434,9 +1423,9 @@ class Tokenizer {
1434
1423
  this.advance(parseInfo);
1435
1424
  break;
1436
1425
  case 126 /* TokenMap.TILDA */:
1437
- if (parseInfo.position < parseInfo.currentPosition) {
1438
- return this.makeToken(parseInfo);
1439
- }
1426
+ // if (parseInfo.position < parseInfo.currentPosition) {
1427
+ // return this.makeToken(parseInfo);
1428
+ // }
1440
1429
  if (this.match(parseInfo, "~=")) {
1441
1430
  this.advance(parseInfo, 2);
1442
1431
  return this.makeToken(parseInfo, EnumToken.IncludeMatchTokenType);
@@ -1445,9 +1434,9 @@ class Tokenizer {
1445
1434
  return this.makeToken(parseInfo, EnumToken.Tilda);
1446
1435
  // case '^':
1447
1436
  case 94 /* TokenMap.CARET */:
1448
- if (parseInfo.position < parseInfo.currentPosition) {
1449
- return this.makeToken(parseInfo);
1450
- }
1437
+ // if (parseInfo.position < parseInfo.currentPosition) {
1438
+ // return this.makeToken(parseInfo);
1439
+ // }
1451
1440
  if (this.match(parseInfo, "^=")) {
1452
1441
  this.advance(parseInfo, 2);
1453
1442
  return this.makeToken(parseInfo, EnumToken.StartMatchTokenType);
@@ -1455,9 +1444,9 @@ class Tokenizer {
1455
1444
  this.advance(parseInfo);
1456
1445
  break;
1457
1446
  case 42 /* TokenMap.STAR */:
1458
- if (parseInfo.position < parseInfo.currentPosition) {
1459
- return this.makeToken(parseInfo);
1460
- }
1447
+ // if (parseInfo.position < parseInfo.currentPosition) {
1448
+ // return this.makeToken(parseInfo);
1449
+ // }
1461
1450
  if (this.match(parseInfo, "*=")) {
1462
1451
  this.advance(parseInfo, 2);
1463
1452
  return this.makeToken(parseInfo, EnumToken.ContainMatchTokenType);
@@ -1471,9 +1460,9 @@ class Tokenizer {
1471
1460
  this.advance(parseInfo);
1472
1461
  return this.makeToken(parseInfo, EnumToken.NestingSelectorTokenType);
1473
1462
  case 124 /* TokenMap.PIPE */:
1474
- if (parseInfo.position < parseInfo.currentPosition) {
1475
- return this.makeToken(parseInfo);
1476
- }
1463
+ // if (parseInfo.position < parseInfo.currentPosition) {
1464
+ // return this.makeToken(parseInfo);
1465
+ // }
1477
1466
  // '||'
1478
1467
  if (this.match(parseInfo, "||")) {
1479
1468
  this.advance(parseInfo, 2);
@@ -1496,9 +1485,9 @@ class Tokenizer {
1496
1485
  this.advance(parseInfo);
1497
1486
  break;
1498
1487
  case 47 /* TokenMap.SLASH */:
1499
- if (parseInfo.position < parseInfo.currentPosition) {
1500
- return this.makeToken(parseInfo);
1501
- }
1488
+ // if (parseInfo.position < parseInfo.currentPosition) {
1489
+ // return this.makeToken(parseInfo);
1490
+ // }
1502
1491
  if (!this.match(parseInfo, "/*")) {
1503
1492
  this.advance(parseInfo);
1504
1493
  return this.makeToken(parseInfo, getSymbolHint(parseInfo, parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset));
@@ -1517,9 +1506,9 @@ class Tokenizer {
1517
1506
  }
1518
1507
  break;
1519
1508
  case 62 /* TokenMap.GREATERTHAN */:
1520
- if (parseInfo.position < parseInfo.currentPosition) {
1521
- return this.makeToken(parseInfo);
1522
- }
1509
+ // if (parseInfo.position < parseInfo.currentPosition) {
1510
+ // return this.makeToken(parseInfo);
1511
+ // }
1523
1512
  if (this.match(parseInfo, ">=")) {
1524
1513
  this.advance(parseInfo, 2);
1525
1514
  return this.makeToken(parseInfo, EnumToken.GteTokenType);
@@ -1558,20 +1547,11 @@ class Tokenizer {
1558
1547
  this.advance(parseInfo);
1559
1548
  break;
1560
1549
  case 92 /* TokenMap.REVERSE_SOLIDUS */:
1561
- // if (!yieldEOFToken && parseInfo.stream.length == parseInfo.currentPosition - parseInfo.offset + 1) {
1562
- // break;
1563
- // }
1564
1550
  this.advance(parseInfo);
1565
1551
  // EOF
1566
- if (!this.peek(parseInfo)) {
1567
- // if (!yieldEOFToken) {
1568
- // break;
1569
- // }
1570
- // end of stream ignore \\
1571
- if (parseInfo.position < parseInfo.currentPosition) {
1572
- return this.makeToken(parseInfo);
1573
- }
1574
- break;
1552
+ // end of stream ignore \\
1553
+ if (!this.peek(parseInfo) && parseInfo.position < parseInfo.currentPosition) {
1554
+ return this.makeToken(parseInfo);
1575
1555
  }
1576
1556
  this.advance(parseInfo);
1577
1557
  break;
@@ -1584,9 +1564,9 @@ class Tokenizer {
1584
1564
  case 46 /* TokenMap.DOT */:
1585
1565
  const codepoint = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + 1);
1586
1566
  if (isIdentStart(codepoint) || codepoint == 45 /* TokenMap.MINUS */) {
1587
- if (parseInfo.position < parseInfo.currentPosition) {
1588
- return this.makeToken(parseInfo);
1589
- }
1567
+ // if (parseInfo.position < parseInfo.currentPosition) {
1568
+ // return this.makeToken(parseInfo);
1569
+ // }
1590
1570
  this.advance(parseInfo);
1591
1571
  let tokensCount = this.consumeIdentToken(parseInfo);
1592
1572
  if (tokensCount > 0) {
@@ -1594,27 +1574,22 @@ class Tokenizer {
1594
1574
  return this.makeToken(parseInfo, EnumToken.ClassSelectorTokenType);
1595
1575
  }
1596
1576
  }
1597
- if (!isDigit(codepoint) && parseInfo.position !== parseInfo.currentPosition) {
1598
- this.makeToken(parseInfo);
1599
- this.advance(parseInfo, 2);
1600
- return this;
1601
- }
1577
+ // if (!isDigit(codepoint) && parseInfo.position !== parseInfo.currentPosition) {
1578
+ // this.makeToken(parseInfo);
1579
+ // this.advance(parseInfo, 2);
1580
+ // return this;
1581
+ // }
1602
1582
  this.advance(parseInfo);
1603
1583
  break;
1604
1584
  default:
1605
1585
  this.advance(parseInfo);
1606
1586
  break;
1607
1587
  }
1608
- // if (!yieldEOFToken && endPosition <= parseInfo.currentPosition - parseInfo.offset + 1) {
1609
- // break;
1610
- // }
1611
1588
  }
1612
- // if (yieldEOFToken) {
1613
1589
  if (parseInfo.position < parseInfo.currentPosition) {
1614
1590
  return this.makeToken(parseInfo);
1615
1591
  }
1616
1592
  return this.makeToken(parseInfo, EnumToken.EOFTokenType);
1617
- // }
1618
1593
  }
1619
1594
  /**
1620
1595
  * tokenize readable stream
@@ -3,6 +3,7 @@ import { tokensfuncDefMap, LOCSTA, mFGT, mFLT, LOCEND, LOCSRCID } from '../../sy
3
3
  import { matchAllSyntaxes, createValidationContext, trimArray } from '../../validation/match.js';
4
4
  import { ValidationSyntaxGroupEnum } from '../../validation/parser/typedef.js';
5
5
  import { getSyntaxRule } from '../../validation/config.js';
6
+ import { equalsIgnoreCase } from './text.js';
6
7
 
7
8
  function parseAtRuleContainerQueryList(stream, context, options = {}) {
8
9
  let matchCount = 0;
@@ -37,7 +38,7 @@ function parseAtRuleContainerQueryList(stream, context, options = {}) {
37
38
  };
38
39
  }
39
40
  {
40
- for (const stream of parts.slice()) {
41
+ for (const stream of parts) {
41
42
  let success = true;
42
43
  let i;
43
44
  let currentScope = new Set();
@@ -156,6 +157,22 @@ function parseAtRuleContainerQueryList(stream, context, options = {}) {
156
157
  [LOCSTA]: names[0][LOCSTA],
157
158
  [LOCEND]: values.at(-1)[LOCEND],
158
159
  });
160
+ const token = tokens[index3 + 1];
161
+ if (token.op.typ === EnumToken.ColonTokenType) {
162
+ let name = token.l.find((t) => t.typ === EnumToken.IdenTokenType);
163
+ if (name != null) {
164
+ if (name.val.startsWith("min-")) {
165
+ name.val = name.val.substring(4);
166
+ // @ts-ignore
167
+ token.op.typ = EnumToken.GteTokenType;
168
+ }
169
+ else if (name.val.startsWith("max-")) {
170
+ name.val = name.val.substring(4);
171
+ // @ts-ignore
172
+ token.op.typ = EnumToken.LteTokenType;
173
+ }
174
+ }
175
+ }
159
176
  // check <style()> or <scroll-state()>
160
177
  }
161
178
  if (tokensfuncDefMap.has(stack.at(-1)?.typ)) {
@@ -247,6 +264,58 @@ function parseAtRuleContainerQueryList(stream, context, options = {}) {
247
264
  };
248
265
  tokens.length = l + 1;
249
266
  expectAndOr = true;
267
+ if (tokens[l].op.typ === EnumToken.AndTokenType) {
268
+ let left = tokens[l].l.find((t) => t.typ != EnumToken.WhitespaceTokenType && t.typ != EnumToken.IdenTokenType);
269
+ let right = tokens[l].r.find((t) => t.typ != EnumToken.WhitespaceTokenType && t.typ != EnumToken.IdenTokenType);
270
+ if (left.typ == EnumToken.ParensTokenType && right.typ == EnumToken.ParensTokenType) {
271
+ left = left.chi.find((t) => t.typ != EnumToken.WhitespaceTokenType && t.typ != EnumToken.IdenTokenType);
272
+ right = right.chi.find((t) => t.typ != EnumToken.WhitespaceTokenType && t.typ != EnumToken.IdenTokenType);
273
+ if (left.typ == EnumToken.MediaQueryConditionTokenType &&
274
+ (mFLT.has(left.op.typ) ||
275
+ mFGT.has(left.op.typ)) &&
276
+ right.typ == EnumToken.MediaQueryConditionTokenType &&
277
+ (mFLT.has(right.op.typ) ||
278
+ mFGT.has(right.op.typ))) {
279
+ const name = left.l.find((t) => t.typ == EnumToken.IdenTokenType);
280
+ const name2 = right.l.find((t) => t.typ == EnumToken.IdenTokenType);
281
+ if (equalsIgnoreCase(name.val, name2.val)) {
282
+ switch (left.op.typ) {
283
+ case EnumToken.LtTokenType:
284
+ left.op.typ = EnumToken.GtTokenType;
285
+ break;
286
+ case EnumToken.LteTokenType:
287
+ left.op.typ = EnumToken.GteTokenType;
288
+ break;
289
+ case EnumToken.GtTokenType:
290
+ left.op.typ = EnumToken.LtTokenType;
291
+ break;
292
+ case EnumToken.GteTokenType:
293
+ left.op.typ = EnumToken.LteTokenType;
294
+ break;
295
+ }
296
+ tokens[l] = {
297
+ typ: EnumToken.ParensTokenType,
298
+ chi: [
299
+ {
300
+ typ: EnumToken.MediaRangeQueryTokenType,
301
+ l: left.r,
302
+ val: [name],
303
+ op1: left.op,
304
+ op2: right.op,
305
+ r: right.r,
306
+ [LOCSRCID]: name[LOCSRCID],
307
+ [LOCSTA]: left[LOCSTA],
308
+ [LOCEND]: right[LOCEND],
309
+ },
310
+ ],
311
+ [LOCSRCID]: name[LOCSRCID],
312
+ [LOCSTA]: left[LOCSTA],
313
+ [LOCEND]: right[LOCEND],
314
+ };
315
+ }
316
+ }
317
+ }
318
+ }
250
319
  }
251
320
  break;
252
321
  }
@@ -190,8 +190,6 @@ function parseMediaqueryList(stream, options) {
190
190
  }
191
191
  }
192
192
  }
193
- // let isValidMFValue = isMFValue(name, left, true);
194
- // isValidMFValue = isMFValue(name, right, true);
195
193
  for (const val of [left, right]) {
196
194
  if (mfInfo?.type === MediaFeatureType.RatioType) {
197
195
  const filteredValues = val.filter((n) => n.typ !== EnumToken.WhitespaceTokenType &&