@@ -5,9 +5,8 @@ var promises = require('node:fs/promises');
55
66var ValidationLevel;
77(function (ValidationLevel) {
8- ValidationLevel[ValidationLevel["None"] = 0] = "None";
9- ValidationLevel[ValidationLevel["Valid"] = 1] = "Valid";
10- ValidationLevel[ValidationLevel["Drop"] = 2] = "Drop";
8+ ValidationLevel[ValidationLevel["Valid"] = 0] = "Valid";
9+ ValidationLevel[ValidationLevel["Drop"] = 1] = "Drop";
1110})(ValidationLevel || (ValidationLevel = {}));
1211exports.EnumToken = void 0;
1312(function (EnumToken) {
@@ -59919,6 +59918,7 @@ async function parseNode(results, context, stats, options, errors, src, map) {
5991959918 if (delim.typ == exports.EnumToken.BlockStartTokenType) {
5992059919 const position = map.get(tokens[0]);
5992159920 const uniq = new Map;
59921+ // const uniqTokens: Token[][] = [[]];
5992259922 parseTokens(tokens, { minify: true }).reduce((acc, curr, index, array) => {
5992359923 if (curr.typ == exports.EnumToken.CommentTokenType) {
5992459924 return acc;
@@ -59934,27 +59934,31 @@ async function parseNode(results, context, stats, options, errors, src, map) {
5993459934 let t = renderToken(curr, { minify: false });
5993559935 if (t == ',') {
5993659936 acc.push([]);
59937+ // uniqTokens.push([]);
5993759938 }
5993859939 else {
5993959940 acc[acc.length - 1].push(t);
59941+ // uniqTokens[uniqTokens.length - 1].push(curr);
5994059942 }
5994159943 return acc;
5994259944 }, [[]]).reduce((acc, curr) => {
59943- // for (let i = 0; i < curr.length; i++) {
59944- //
59945- // if (curr[i] == '*' && i + 1 < curr.length) {
59946- //
59947- // curr.splice(i, curr[i + 1] == ' ' ? 2 : 1);
59948- // i--;
59949- // }
59950- // }
59945+ let i = 0;
59946+ for (; i < curr.length; i++) {
59947+ if (i + 1 < curr.length && curr[i] == '*') {
59948+ if (curr[i] == '*') {
59949+ let index = curr[i + 1] == ' ' ? 2 : 1;
59950+ if (!['>', '~', '+'].includes(curr[index])) {
59951+ curr.splice(i, index);
59952+ }
59953+ }
59954+ }
59955+ }
5995159956 acc.set(curr.join(''), curr);
5995259957 return acc;
5995359958 }, uniq);
5995459959 const ruleType = context.typ == exports.EnumToken.AtRuleNodeType && context.nam == 'keyframes' ? exports.EnumToken.KeyFrameRuleNodeType : exports.EnumToken.RuleNodeType;
5995559960 if (ruleType == exports.EnumToken.RuleNodeType) {
59956- parseSelector(tokens);
59957- const valid = validateSelector(tokens, options, context);
59961+ const valid = validateSelector(parseSelector(tokens), options, context);
5995859962 if (valid.valid != ValidationLevel.Valid) {
5995959963 const node = {
5996059964 typ: exports.EnumToken.InvalidRuleTokenType,
@@ -59967,14 +59971,12 @@ async function parseNode(results, context, stats, options, errors, src, map) {
5996759971 message: valid.error + ' - "' + tokens.reduce((acc, curr) => acc + renderToken(curr, { minify: false }), '') + '"',
5996859972 location: { src, ...(map.get(valid.node) ?? position) }
5996959973 });
59970- // @ts-ignore
5997159974 context.chi.push(node);
5997259975 return node;
5997359976 }
5997459977 }
5997559978 const node = {
5997659979 typ: ruleType,
59977- // @ts-ignore
5997859980 sel: [...uniq.keys()].join(','),
5997959981 chi: []
5998059982 };
@@ -60174,12 +60176,13 @@ function parseSelector(tokens) {
6017460176 }
6017560177 }
6017660178 let i = 0;
60179+ const combinators = [
60180+ exports.EnumToken.ChildCombinatorTokenType,
60181+ exports.EnumToken.NextSiblingCombinatorTokenType,
60182+ exports.EnumToken.SubsequentSiblingCombinatorTokenType
60183+ ];
6017760184 for (; i < tokens.length; i++) {
60178- if ([
60179- exports.EnumToken.ChildCombinatorTokenType,
60180- exports.EnumToken.NextSiblingCombinatorTokenType,
60181- exports.EnumToken.SubsequentSiblingCombinatorTokenType
60182- ].includes(tokens[i].typ)) {
60185+ if (combinators.includes(tokens[i].typ)) {
6018360186 if (i + 1 < tokens.length && [exports.EnumToken.WhitespaceTokenType, exports.EnumToken.DescendantCombinatorTokenType].includes(tokens[i + 1].typ)) {
6018460187 tokens.splice(i + 1, 1);
6018560188 }
@@ -60951,7 +60954,12 @@ function replaceCompoundLiteral(selector, replace) {
6095160954 return 1;
6095260955 }
6095360956 return b == '&' ? -1 : 0;
60954- }).reduce((acc, curr) => acc + (curr == '&' ? replace : curr), '');
60957+ }).reduce((acc, curr) => {
60958+ if (acc.length > 0 && curr == '&' && (replace.charAt(0) != '.' || replace.includes(' '))) {
60959+ return acc + ':is(' + replace + ')';
60960+ }
60961+ return acc + (curr == '&' ? replace : curr);
60962+ }, '');
6095560963}
6095660964
6095760965var ValidationTokenEnum;
@@ -62631,7 +62639,6 @@ function reduceSelector(selector) {
6263162639 return null;
6263262640 }
6263362641 selector = selector.reduce((acc, curr) => {
62634- // trim :is()
6263562642 // @ts-ignore
6263662643 if (curr.length > 0 && curr.at(-1).startsWith(':is(')) {
6263762644 // @ts-ignore
@@ -62688,9 +62695,6 @@ function reduceSelector(selector) {
6268862695 if (optimized[1] == ' ') {
6268962696 optimized.splice(0, 2);
6269062697 }
62691- // else if (combinators.includes(optimized[1])) {
62692- //
62693- // }
6269462698 }
6269562699 if (optimized.length == 0 ||
6269662700 (optimized[0].charAt(0) == '&' ||
0 commit comments