|
10748 | 10748 | syntax: "cover | contain | entry | exit | entry-crossing | exit-crossing" |
10749 | 10749 | }, |
10750 | 10750 | "track-breadth": { |
10751 | | - syntax: "<length-percentage> | <flex> | min-content | max-content | auto" |
| 10751 | + syntax: "<length-percentage> | <flex> | min-content | max-content | auto | <-non-standard-size>>" |
10752 | 10752 | }, |
10753 | 10753 | "track-list": { |
10754 | 10754 | syntax: "[ <line-names>? [ <track-size> | <track-repeat> ] ]+ <line-names>?" |
|
13344 | 13344 | const allValues = getSyntaxConfig()["declarations" /* ValidationSyntaxGroupEnum.Declarations */].all.syntax.trim().split(/[\s|]+/g); |
13345 | 13345 | function createContext(input) { |
13346 | 13346 | const values = input.slice(); |
13347 | | - const result = values.slice(); |
| 13347 | + const result = values.filter(token => token.typ != exports.EnumToken.CommentTokenType).slice(); |
13348 | 13348 | if (result.at(-1)?.typ == exports.EnumToken.WhitespaceTokenType) { |
13349 | 13349 | result.pop(); |
13350 | 13350 | } |
|
13579 | 13579 | } |
13580 | 13580 | return { |
13581 | 13581 | valid: success ? SyntaxValidationResult.Valid : SyntaxValidationResult.Drop, |
13582 | | - node: context.current(), |
| 13582 | + node: context.peek(), |
13583 | 13583 | syntax, |
13584 | | - error: success ? '' : `could not match atLeastOnce: ${renderSyntax(syntax)}`, |
| 13584 | + error: success ? '' : `could not match syntax: ${renderSyntax(syntax)}`, |
13585 | 13585 | context |
13586 | 13586 | }; |
13587 | 13587 | } |
|
13618 | 13618 | valid: SyntaxValidationResult.Drop, |
13619 | 13619 | node: context.peek(), |
13620 | 13620 | syntax, |
13621 | | - error: `could not match list: ${renderSyntax(syntax)}`, |
| 13621 | + error: `could not match syntax: ${renderSyntax(syntax)}`, |
13622 | 13622 | context |
13623 | 13623 | }; |
13624 | 13624 | } |
|
13650 | 13650 | } |
13651 | 13651 | return { |
13652 | 13652 | valid: success ? SyntaxValidationResult.Valid : SyntaxValidationResult.Drop, |
13653 | | - node: context.current(), |
| 13653 | + node: context.peek(), |
13654 | 13654 | syntax, |
13655 | 13655 | error: '', |
13656 | 13656 | context |
|
13675 | 13675 | } |
13676 | 13676 | return { |
13677 | 13677 | valid: sucesss ? SyntaxValidationResult.Valid : SyntaxValidationResult.Drop, |
13678 | | - node: context.current(), |
| 13678 | + node: context.peek(), |
13679 | 13679 | syntax, |
13680 | 13680 | error: sucesss ? '' : `expected ${renderSyntax(syntax)} ${syntax.occurence.min} to ${syntax.occurence.max} occurences, got ${counter}`, |
13681 | 13681 | context |
|
13699 | 13699 | } |
13700 | 13700 | return { |
13701 | 13701 | valid: SyntaxValidationResult.Drop, |
13702 | | - node: context.current(), |
| 13702 | + node: context.peek(), |
13703 | 13703 | syntax, |
13704 | 13704 | error: `expected '${ValidationTokenEnum[syntax.typ].toLowerCase()}', got '${context.done() ? null : renderToken(context.peek())}'`, |
13705 | 13705 | context |
|
14158 | 14158 | } |
14159 | 14159 | return matched[0] ?? { |
14160 | 14160 | valid: SyntaxValidationResult.Drop, |
14161 | | - node: context.current(), |
| 14161 | + node: context.peek(), |
14162 | 14162 | syntax: null, |
14163 | | - error: success ? '' : `could not match someOf: ${syntaxes.reduce((acc, curr) => acc + (acc.length > 0 ? ' | ' : '') + curr.reduce((acc, curr) => acc + renderSyntax(curr), ''), '')}`, |
| 14163 | + error: success ? '' : `could not match syntax: ${syntaxes.reduce((acc, curr) => acc + (acc.length > 0 ? ' | ' : '') + curr.reduce((acc, curr) => acc + renderSyntax(curr), ''), '')}`, |
14164 | 14164 | context |
14165 | 14165 | }; |
14166 | 14166 | } |
|
14182 | 14182 | } |
14183 | 14183 | return { |
14184 | 14184 | valid: success ? SyntaxValidationResult.Valid : SyntaxValidationResult.Drop, |
14185 | | - node: context.current(), |
| 14185 | + node: context.peek(), |
14186 | 14186 | syntax: null, |
14187 | | - error: success ? '' : `could not match anyOf: ${syntaxes.reduce((acc, curr) => acc + '[' + curr.reduce((acc, curr) => acc + renderSyntax(curr), '') + ']', '')}`, |
| 14187 | + error: success ? '' : `could not match syntax: ${syntaxes.reduce((acc, curr) => acc + '[' + curr.reduce((acc, curr) => acc + renderSyntax(curr), '') + ']', '')}`, |
14188 | 14188 | context |
14189 | 14189 | }; |
14190 | 14190 | } |
|
14274 | 14274 | const success = syntax.length == 0; |
14275 | 14275 | return { |
14276 | 14276 | valid: success ? SyntaxValidationResult.Valid : SyntaxValidationResult.Drop, |
14277 | | - node: context.current(), |
| 14277 | + node: context.peek(), |
14278 | 14278 | syntax: syntax?.[0]?.[0] ?? null, |
14279 | | - error: `could not match allOf: ${syntax.reduce((acc, curr) => acc + '[' + curr.reduce((acc, curr) => acc + renderSyntax(curr), '') + ']', '')}`, |
| 14279 | + error: `could not match syntax: ${syntax.reduce((acc, curr) => acc + '[' + curr.reduce((acc, curr) => acc + renderSyntax(curr), '') + ']', '')}`, |
14280 | 14280 | context: success ? con : context |
14281 | 14281 | }; |
14282 | 14282 | } |
|
16359 | 16359 | } |
16360 | 16360 | } |
16361 | 16361 | catch (error) { |
16362 | | - // console.error(error); |
16363 | 16362 | // @ts-ignore |
16364 | 16363 | errors.push({ action: 'ignore', message: 'doParse: ' + error.message, error }); |
16365 | 16364 | } |
|
16632 | 16631 | node.loc = loc; |
16633 | 16632 | node.loc.end = { ...map.get(delim).end }; |
16634 | 16633 | } |
16635 | | - // if (options.validation) { |
16636 | 16634 | let isValid = true; |
16637 | 16635 | if (node.nam == 'else') { |
16638 | 16636 | const prev = getLastNode(context); |
@@ -16909,12 +16907,11 @@ |
16909 | 16907 | value: valid.valid == SyntaxValidationResult.Valid |
16910 | 16908 | }); |
16911 | 16909 | if (valid.valid == SyntaxValidationResult.Drop) { |
16912 | | - // console.error({result, valid}); |
16913 | | - // console.error(JSON.stringify({result, options, valid}, null, 1)); |
16914 | 16910 | errors.push({ |
16915 | 16911 | action: 'drop', |
16916 | 16912 | message: valid.error, |
16917 | 16913 | syntax: valid.syntax, |
| 16914 | + node: valid.node, |
16918 | 16915 | location: map.get(valid.node) ?? valid.node?.loc ?? result.loc ?? location |
16919 | 16916 | }); |
16920 | 16917 | if (!options.lenient) { |
|
17075 | 17072 | break; |
17076 | 17073 | } |
17077 | 17074 | if (valueIndex == -1) { |
17078 | | - // @ts-ignore |
17079 | | - // value.chi[nameIndex].typ = EnumToken.MediaFeatureTokenType; |
17080 | 17075 | continue; |
17081 | | - // return tokens; |
17082 | 17076 | } |
17083 | 17077 | for (i = nameIndex + 1; i < value.chi.length; i++) { |
17084 | 17078 | if ([ |
|
17209 | 17203 | break; |
17210 | 17204 | } |
17211 | 17205 | // @ts-ignore |
17212 | | - // @ts-ignore |
17213 | 17206 | delete value.val; |
17214 | 17207 | } |
17215 | 17208 | } |
|
17498 | 17491 | } |
17499 | 17492 | // @ts-ignore |
17500 | 17493 | if (attr.chi.length > 1) { |
17501 | | - /*(<AttrToken>t).chi =*/ |
17502 | 17494 | // @ts-ignore |
17503 | 17495 | parseTokens(attr.chi, t.typ); |
17504 | 17496 | } |
|
17718 | 17710 | // @ts-ignore |
17719 | 17711 | if (t.chi.length > 0) { |
17720 | 17712 | if (t.typ == exports.EnumToken.PseudoClassFuncTokenType && t.val == ':is' && options.minify) { |
17721 | | - // |
17722 | 17713 | const count = t.chi.filter((t) => t.typ != exports.EnumToken.CommentTokenType).length; |
17723 | 17714 | if (count == 1 || |
17724 | 17715 | (i == 0 && |
@@ -21037,12 +21028,32 @@ |
21037 | 21028 | if (!wrap) { |
21038 | 21029 | wrap = selector.some((s) => s[0] != '&'); |
21039 | 21030 | } |
21040 | | - let rule = selector.map(s => { |
21041 | | - if (s[0] == '&') { |
21042 | | - s.splice(0, 1, ...node.optimized.optimized); |
| 21031 | + let rule = null; |
| 21032 | + const optimized = node.optimized.optimized.slice(); |
| 21033 | + if (optimized.length > 1) { |
| 21034 | + const check = optimized.at(-2); |
| 21035 | + if (!combinators.includes(check)) { |
| 21036 | + let last = optimized.pop(); |
| 21037 | + wrap = false; |
| 21038 | + rule = optimized.join('') + `:is(${selector.map(s => { |
| 21039 | + if (s[0] == '&') { |
| 21040 | + s.splice(0, 1, last); |
| 21041 | + } |
| 21042 | + else { |
| 21043 | + s.unshift(last); |
| 21044 | + } |
| 21045 | + return s.join(''); |
| 21046 | + }).join(',')})`; |
21043 | 21047 | } |
21044 | | - return s.join(''); |
21045 | | - }).join(','); |
| 21048 | + } |
| 21049 | + if (rule == null) { |
| 21050 | + rule = selector.map(s => { |
| 21051 | + if (s[0] == '&') { |
| 21052 | + s.splice(0, 1, ...node.optimized.optimized); |
| 21053 | + } |
| 21054 | + return s.join(''); |
| 21055 | + }).join(','); |
| 21056 | + } |
21046 | 21057 | // @ts-ignore |
21047 | 21058 | let sel = wrap ? node.optimized.optimized.join('') + `:is(${rule})` : rule; |
21048 | 21059 | if (rule.includes('&')) { |
|
0 commit comments