@tbela99/css-parser 1.4.1 → 1.4.3
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.
- package/.nyc_output/4874b20e-6f53-4d7a-be5a-cf68316925f2.json +1 -0
- package/.nyc_output/6193bc4c-6f5f-4898-8950-c628825e6342.json +1 -0
- package/.nyc_output/processinfo/4874b20e-6f53-4d7a-be5a-cf68316925f2.json +1 -0
- package/.nyc_output/processinfo/6193bc4c-6f5f-4898-8950-c628825e6342.json +1 -0
- package/.repl_history +4 -0
- package/CHANGELOG.md +168 -4
- package/README.md +82 -0
- package/badges/coverage.svg +20 -0
- package/deno.lock +2861 -0
- package/dist/config.json.js +33 -1
- package/dist/index-umd-web.js +24393 -18479
- package/dist/index.cjs +27430 -21519
- package/dist/index.d.ts +1403 -933
- package/dist/lib/ast/clone.d.ts +10 -0
- package/dist/lib/ast/clone.js +45 -0
- package/dist/lib/ast/expand.d.ts +14 -0
- package/dist/lib/ast/expand.js +89 -64
- package/dist/lib/ast/features/calc.d.ts +10 -0
- package/dist/lib/ast/features/calc.js +62 -24
- package/dist/lib/ast/features/if.d.ts +10 -0
- package/dist/lib/ast/features/if.js +215 -0
- package/dist/lib/ast/features/index.d.ts +6 -0
- package/dist/lib/ast/features/index.js +1 -0
- package/dist/lib/ast/features/inlinecssvariables.d.ts +15 -0
- package/dist/lib/ast/features/inlinecssvariables.js +32 -27
- package/dist/lib/ast/features/prefix.d.ts +8 -0
- package/dist/lib/ast/features/prefix.js +68 -43
- package/dist/lib/ast/features/shorthand.d.ts +12 -0
- package/dist/lib/ast/features/shorthand.js +6 -9
- package/dist/lib/ast/features/transform.d.ts +10 -0
- package/dist/lib/ast/features/transform.js +9 -13
- package/dist/lib/ast/features/type.d.ts +15 -0
- package/dist/lib/ast/find.d.ts +165 -0
- package/dist/lib/ast/find.js +175 -0
- package/dist/lib/ast/math/expression.d.ts +18 -0
- package/dist/lib/ast/math/expression.js +140 -98
- package/dist/lib/ast/math/math.d.ts +6 -0
- package/dist/lib/ast/math/math.js +30 -41
- package/dist/lib/ast/minify.d.ts +19 -0
- package/dist/lib/ast/minify.js +543 -215
- package/dist/lib/ast/transform/compute.d.ts +8 -0
- package/dist/lib/ast/transform/compute.js +82 -69
- package/dist/lib/ast/transform/matrix.d.ts +22 -0
- package/dist/lib/ast/transform/matrix.js +12 -26
- package/dist/lib/ast/transform/minify.d.ts +5 -0
- package/dist/lib/ast/transform/minify.js +20 -20
- package/dist/lib/ast/transform/perspective.d.ts +3 -0
- package/dist/lib/ast/transform/perspective.js +1 -1
- package/dist/lib/ast/transform/rotate.d.ts +12 -0
- package/dist/lib/ast/transform/rotate.js +1 -1
- package/dist/lib/ast/transform/scale.d.ts +6 -0
- package/dist/lib/ast/transform/scale.js +1 -1
- package/dist/lib/ast/transform/skew.d.ts +4 -0
- package/dist/lib/ast/transform/skew.js +1 -1
- package/dist/lib/ast/transform/translate.d.ts +6 -0
- package/dist/lib/ast/transform/translate.js +1 -1
- package/dist/lib/ast/transform/utils.d.ts +9 -0
- package/dist/lib/ast/types.d.ts +903 -0
- package/dist/lib/ast/types.js +277 -23
- package/dist/lib/ast/walk.d.ts +162 -0
- package/dist/lib/ast/walk.js +116 -60
- package/dist/lib/fs/resolve.d.ts +20 -0
- package/dist/lib/fs/resolve.js +37 -45
- package/dist/lib/parser/declaration/list.d.ts +16 -0
- package/dist/lib/parser/declaration/list.js +26 -24
- package/dist/lib/parser/declaration/map.d.ts +15 -0
- package/dist/lib/parser/declaration/map.js +140 -95
- package/dist/lib/parser/declaration/set.d.ts +9 -0
- package/dist/lib/parser/declaration/set.js +30 -25
- package/dist/lib/parser/node.d.ts +7 -0
- package/dist/lib/parser/parse.d.ts +107 -0
- package/dist/lib/parser/parse.js +1454 -1445
- package/dist/lib/parser/tokenize.d.ts +57 -0
- package/dist/lib/parser/tokenize.js +557 -404
- package/dist/lib/parser/utils/at-rule-container.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-container.js +486 -0
- package/dist/lib/parser/utils/at-rule-font-feature-values.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-font-feature-values.js +13 -0
- package/dist/lib/parser/utils/at-rule-generic.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-generic.js +118 -0
- package/dist/lib/parser/utils/at-rule-import.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-import.js +393 -0
- package/dist/lib/parser/utils/at-rule-media.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-media.js +603 -0
- package/dist/lib/parser/utils/at-rule-page.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-page.js +28 -0
- package/dist/lib/parser/utils/at-rule-support.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-support.js +366 -0
- package/dist/lib/parser/utils/at-rule-token.d.ts +1 -0
- package/dist/lib/parser/utils/at-rule-when-else.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-when-else.js +363 -0
- package/dist/lib/parser/utils/at-rule.d.ts +13 -0
- package/dist/lib/parser/utils/at-rule.js +37 -0
- package/dist/lib/parser/utils/cache.d.ts +6 -0
- package/dist/lib/parser/utils/cache.js +19 -0
- package/dist/lib/parser/utils/config.d.ts +2 -0
- package/dist/lib/parser/utils/config.js +1 -0
- package/dist/lib/parser/utils/declaration-list.d.ts +5 -0
- package/dist/lib/parser/utils/declaration.d.ts +18 -0
- package/dist/lib/parser/utils/declaration.js +569 -91
- package/dist/lib/parser/utils/eq.d.ts +1 -0
- package/dist/lib/parser/utils/hash.d.ts +21 -0
- package/dist/lib/parser/utils/hash.js +1 -1
- package/dist/lib/parser/utils/selector.d.ts +5 -0
- package/dist/lib/parser/utils/selector.js +476 -0
- package/dist/lib/parser/utils/text.d.ts +3 -0
- package/dist/lib/parser/utils/text.js +17 -1
- package/dist/lib/parser/utils/token.d.ts +14 -0
- package/dist/lib/parser/utils/token.js +102 -0
- package/dist/lib/parser/utils/type.d.ts +2 -0
- package/dist/lib/parser/utils/type.js +29 -18
- package/dist/lib/renderer/render.d.ts +28 -0
- package/dist/lib/renderer/render.js +421 -262
- package/dist/lib/renderer/sourcemap/lib/encode.d.ts +1 -0
- package/dist/lib/renderer/sourcemap/sourcemap.d.ts +26 -0
- package/dist/lib/renderer/sourcemap/sourcemap.js +17 -7
- package/dist/lib/syntax/color/a98rgb.d.ts +2 -0
- package/dist/lib/syntax/color/a98rgb.js +8 -12
- package/dist/lib/syntax/color/cmyk.d.ts +10 -0
- package/dist/lib/syntax/color/cmyk.js +23 -21
- package/dist/lib/syntax/color/color-mix.d.ts +2 -0
- package/dist/lib/syntax/color/color-mix.js +88 -77
- package/dist/lib/syntax/color/color.d.ts +42 -0
- package/dist/lib/syntax/color/color.js +65 -68
- package/dist/lib/syntax/color/hex.d.ts +16 -0
- package/dist/lib/syntax/color/hex.js +27 -31
- package/dist/lib/syntax/color/hsl.d.ts +20 -0
- package/dist/lib/syntax/color/hsl.js +5 -12
- package/dist/lib/syntax/color/hsv.d.ts +2 -0
- package/dist/lib/syntax/color/hwb.d.ts +21 -0
- package/dist/lib/syntax/color/hwb.js +8 -21
- package/dist/lib/syntax/color/lab.d.ts +25 -0
- package/dist/lib/syntax/color/lab.js +20 -21
- package/dist/lib/syntax/color/lch.d.ts +23 -0
- package/dist/lib/syntax/color/lch.js +13 -15
- package/dist/lib/syntax/color/oklab.d.ts +22 -0
- package/dist/lib/syntax/color/oklab.js +20 -39
- package/dist/lib/syntax/color/oklch.d.ts +20 -0
- package/dist/lib/syntax/color/oklch.js +14 -16
- package/dist/lib/syntax/color/p3.d.ts +6 -0
- package/dist/lib/syntax/color/p3.js +0 -8
- package/dist/lib/syntax/color/prophotorgb.d.ts +2 -0
- package/dist/lib/syntax/color/rec2020.d.ts +2 -0
- package/dist/lib/syntax/color/rec2020.js +9 -13
- package/dist/lib/syntax/color/relativecolor.d.ts +13 -0
- package/dist/lib/syntax/color/relativecolor.js +68 -41
- package/dist/lib/syntax/color/rgb.d.ts +20 -0
- package/dist/lib/syntax/color/rgb.js +14 -18
- package/dist/lib/syntax/color/srgb.d.ts +23 -0
- package/dist/lib/syntax/color/srgb.js +27 -26
- package/dist/lib/syntax/color/utils/components.d.ts +2 -0
- package/dist/lib/syntax/color/utils/components.js +30 -14
- package/dist/lib/syntax/color/utils/distance.d.ts +18 -0
- package/dist/lib/syntax/color/utils/distance.js +1 -8
- package/dist/lib/syntax/color/utils/matrix.d.ts +6 -0
- package/dist/lib/syntax/color/xyz.d.ts +5 -0
- package/dist/lib/syntax/color/xyz.js +8 -20
- package/dist/lib/syntax/color/xyzd50.d.ts +4 -0
- package/dist/lib/syntax/color/xyzd50.js +6 -20
- package/dist/lib/syntax/constants.d.ts +67 -0
- package/dist/lib/syntax/constants.js +436 -0
- package/dist/lib/syntax/syntax.d.ts +38 -0
- package/dist/lib/syntax/syntax.js +533 -568
- package/dist/lib/validation/config.d.ts +14 -0
- package/dist/lib/validation/config.js +72 -33
- package/dist/lib/validation/config.json.js +1159 -74
- package/dist/lib/validation/json.d.ts +2 -0
- package/dist/lib/validation/match.d.ts +38 -0
- package/dist/lib/validation/match.js +2985 -0
- package/dist/lib/validation/parser/parse.d.ts +8 -0
- package/dist/lib/validation/parser/parse.js +684 -935
- package/dist/lib/validation/parser/typedef.d.ts +95 -0
- package/dist/lib/validation/parser/typedef.js +100 -0
- package/dist/lib/validation/utils/list.d.ts +4 -0
- package/dist/lib/validation/utils/list.js +4 -11
- package/dist/lib/validation/utils/whitespace.d.ts +2 -0
- package/dist/lib/validation/utils/whitespace.js +2 -8
- package/dist/node.d.ts +207 -0
- package/dist/node.js +53 -47
- package/dist/web.d.ts +169 -0
- package/dist/web.js +50 -41
- package/package.json +18 -13
- package/playground/index.html +1328 -0
- package/playground/sw.js +55 -0
- package/playground/tree.js +176 -0
- package/dist/lib/syntax/color/utils/constants.js +0 -214
- package/dist/lib/syntax/utils.js +0 -70
- package/dist/lib/validation/at-rules/container.js +0 -342
- package/dist/lib/validation/at-rules/counter-style.js +0 -90
- package/dist/lib/validation/at-rules/custom-media.js +0 -50
- package/dist/lib/validation/at-rules/document.js +0 -89
- package/dist/lib/validation/at-rules/else.js +0 -5
- package/dist/lib/validation/at-rules/font-feature-values.js +0 -63
- package/dist/lib/validation/at-rules/import.js +0 -150
- package/dist/lib/validation/at-rules/keyframes.js +0 -67
- package/dist/lib/validation/at-rules/layer.js +0 -41
- package/dist/lib/validation/at-rules/media.js +0 -255
- package/dist/lib/validation/at-rules/namespace.js +0 -81
- package/dist/lib/validation/at-rules/page-margin-box.js +0 -64
- package/dist/lib/validation/at-rules/page.js +0 -100
- package/dist/lib/validation/at-rules/supports.js +0 -295
- package/dist/lib/validation/at-rules/when.js +0 -185
- package/dist/lib/validation/atrule.js +0 -184
- package/dist/lib/validation/selector.js +0 -36
- package/dist/lib/validation/syntax.js +0 -1073
- package/dist/lib/validation/syntaxes/complex-selector-list.js +0 -27
- package/dist/lib/validation/syntaxes/complex-selector.js +0 -52
- package/dist/lib/validation/syntaxes/compound-selector.js +0 -196
- package/dist/lib/validation/syntaxes/family-name.js +0 -57
- package/dist/lib/validation/syntaxes/keyframe-selector.js +0 -36
- package/dist/lib/validation/syntaxes/layer-name.js +0 -57
- package/dist/lib/validation/syntaxes/relative-selector-list.js +0 -31
- package/dist/lib/validation/syntaxes/relative-selector.js +0 -38
- package/dist/lib/validation/syntaxes/selector-list.js +0 -5
- package/dist/lib/validation/syntaxes/selector.js +0 -5
- package/dist/lib/validation/syntaxes/url.js +0 -40
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { SyntaxValidationResult, EnumToken } from '../ast/types.js';
|
|
2
|
-
import '../ast/minify.js';
|
|
3
|
-
import '../ast/walk.js';
|
|
4
|
-
import '../parser/parse.js';
|
|
5
|
-
import '../parser/tokenize.js';
|
|
6
|
-
import '../parser/utils/config.js';
|
|
7
|
-
import '../syntax/color/utils/constants.js';
|
|
8
|
-
import '../renderer/sourcemap/lib/encode.js';
|
|
9
|
-
import { getSyntaxConfig, getParsedSyntax } from './config.js';
|
|
10
|
-
import { validateAtRuleMedia } from './at-rules/media.js';
|
|
11
|
-
import { validateAtRuleCounterStyle } from './at-rules/counter-style.js';
|
|
12
|
-
import { validateAtRulePage } from './at-rules/page.js';
|
|
13
|
-
import { validateAtRulePageMarginBox } from './at-rules/page-margin-box.js';
|
|
14
|
-
import { validateAtRuleSupports } from './at-rules/supports.js';
|
|
15
|
-
import { validateAtRuleImport } from './at-rules/import.js';
|
|
16
|
-
import { validateAtRuleLayer } from './at-rules/layer.js';
|
|
17
|
-
import { validateAtRuleFontFeatureValues } from './at-rules/font-feature-values.js';
|
|
18
|
-
import { validateAtRuleNamespace } from './at-rules/namespace.js';
|
|
19
|
-
import { validateAtRuleDocument } from './at-rules/document.js';
|
|
20
|
-
import { validateAtRuleWhen } from './at-rules/when.js';
|
|
21
|
-
import { validateAtRuleElse } from './at-rules/else.js';
|
|
22
|
-
import { validateAtRuleContainer } from './at-rules/container.js';
|
|
23
|
-
import { validateAtRuleCustomMedia } from './at-rules/custom-media.js';
|
|
24
|
-
|
|
25
|
-
function validateAtRule(atRule, options, root) {
|
|
26
|
-
if (atRule.nam == 'charset') {
|
|
27
|
-
const valid = atRule.val.match(/^"[a-zA-Z][a-zA-Z0-9_-]+"$/i) != null;
|
|
28
|
-
return {
|
|
29
|
-
valid: valid ? SyntaxValidationResult.Valid : SyntaxValidationResult.Drop,
|
|
30
|
-
node: atRule,
|
|
31
|
-
syntax: null,
|
|
32
|
-
error: ''
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
if (['font-face', 'view-transition', 'starting-style'].includes(atRule.nam)) {
|
|
36
|
-
return {
|
|
37
|
-
valid: SyntaxValidationResult.Valid,
|
|
38
|
-
node: atRule,
|
|
39
|
-
syntax: '@' + atRule.nam,
|
|
40
|
-
error: ''
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
if (atRule.nam == 'media') {
|
|
44
|
-
return validateAtRuleMedia(atRule);
|
|
45
|
-
}
|
|
46
|
-
if (atRule.nam == 'import') {
|
|
47
|
-
return validateAtRuleImport(atRule);
|
|
48
|
-
}
|
|
49
|
-
if (atRule.nam == 'supports') {
|
|
50
|
-
return validateAtRuleSupports(atRule);
|
|
51
|
-
}
|
|
52
|
-
if (atRule.nam == 'counter-style') {
|
|
53
|
-
return validateAtRuleCounterStyle(atRule);
|
|
54
|
-
}
|
|
55
|
-
if (atRule.nam == 'layer') {
|
|
56
|
-
return validateAtRuleLayer(atRule);
|
|
57
|
-
}
|
|
58
|
-
if (atRule.nam == 'font-feature-values') {
|
|
59
|
-
return validateAtRuleFontFeatureValues(atRule);
|
|
60
|
-
}
|
|
61
|
-
if (atRule.nam == 'namespace') {
|
|
62
|
-
return validateAtRuleNamespace(atRule);
|
|
63
|
-
}
|
|
64
|
-
if (atRule.nam == 'when') {
|
|
65
|
-
return validateAtRuleWhen(atRule);
|
|
66
|
-
}
|
|
67
|
-
if (atRule.nam == 'else') {
|
|
68
|
-
return validateAtRuleElse(atRule);
|
|
69
|
-
}
|
|
70
|
-
if (atRule.nam == 'container') {
|
|
71
|
-
return validateAtRuleContainer(atRule);
|
|
72
|
-
}
|
|
73
|
-
if (atRule.nam == 'document') {
|
|
74
|
-
return validateAtRuleDocument(atRule);
|
|
75
|
-
}
|
|
76
|
-
if (atRule.nam == 'custom-media') {
|
|
77
|
-
return validateAtRuleCustomMedia(atRule);
|
|
78
|
-
}
|
|
79
|
-
if (['position-try', 'property', 'font-palette-values'].includes(atRule.nam)) {
|
|
80
|
-
if (!Array.isArray(atRule.tokens) || atRule.tokens.length == 0) {
|
|
81
|
-
return {
|
|
82
|
-
valid: SyntaxValidationResult.Drop,
|
|
83
|
-
node: atRule,
|
|
84
|
-
syntax: '@' + atRule.nam,
|
|
85
|
-
error: 'expected prelude'
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
if (!('chi' in atRule)) {
|
|
89
|
-
return {
|
|
90
|
-
valid: SyntaxValidationResult.Drop,
|
|
91
|
-
node: atRule,
|
|
92
|
-
syntax: '@' + atRule.nam,
|
|
93
|
-
error: 'expected body'
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
const chi = atRule.tokens.filter((t) => t.typ != EnumToken.WhitespaceTokenType && t.typ != EnumToken.CommentTokenType);
|
|
97
|
-
if (chi.length != 1) {
|
|
98
|
-
return {
|
|
99
|
-
valid: SyntaxValidationResult.Drop,
|
|
100
|
-
node: atRule,
|
|
101
|
-
syntax: '@' + atRule.nam,
|
|
102
|
-
error: 'expected ' + (atRule.nam == 'property' ? 'custom-property-name' : 'dashed-ident')
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
if (chi[0].typ != EnumToken.DashedIdenTokenType) {
|
|
106
|
-
// @ts-ignore
|
|
107
|
-
return {
|
|
108
|
-
valid: SyntaxValidationResult.Drop,
|
|
109
|
-
node: atRule,
|
|
110
|
-
syntax: '@' + atRule.nam,
|
|
111
|
-
error: 'expected ' + (atRule.nam == 'property' ? 'custom-property-name' : 'dashed-ident')
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
// @ts-ignore
|
|
115
|
-
return {
|
|
116
|
-
valid: SyntaxValidationResult.Valid,
|
|
117
|
-
node: atRule,
|
|
118
|
-
syntax: '@' + atRule.nam,
|
|
119
|
-
error: ''
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
// scope
|
|
123
|
-
if (atRule.nam == 'page') {
|
|
124
|
-
return validateAtRulePage(atRule);
|
|
125
|
-
}
|
|
126
|
-
if (['top-left-corner', 'top-left', 'top-center', 'top-right', 'top-right-corner', 'bottom-left-corner', 'bottom-left', 'bottom-center', 'bottom-right', 'bottom-right-corner', 'left-top', 'left-middle', 'left-bottom', 'right-top', 'right-middle', 'right-bottom'].includes(atRule.nam)) {
|
|
127
|
-
if (!(root == null || (root.typ == EnumToken.AtRuleNodeType && root.nam == 'page'))) {
|
|
128
|
-
// @ts-ignore
|
|
129
|
-
return {
|
|
130
|
-
valid: SyntaxValidationResult.Drop,
|
|
131
|
-
node: atRule,
|
|
132
|
-
syntax: '@page',
|
|
133
|
-
error: 'not allowed here'
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
return validateAtRulePageMarginBox(atRule);
|
|
137
|
-
}
|
|
138
|
-
// handle keyframe as special case
|
|
139
|
-
// check if the node exists
|
|
140
|
-
const config = getSyntaxConfig();
|
|
141
|
-
let name = '@' + atRule.nam;
|
|
142
|
-
if (!(name in config.atRules)) {
|
|
143
|
-
if (name.charAt(1) == '-') {
|
|
144
|
-
name = name.replace(/@-[a-zA-Z]+-([a-zA-Z][a-zA-Z0-9_-]*)/, '@$1');
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (!(name in config.atRules)) {
|
|
148
|
-
if (options.lenient) {
|
|
149
|
-
return {
|
|
150
|
-
valid: SyntaxValidationResult.Lenient,
|
|
151
|
-
node: atRule,
|
|
152
|
-
syntax: null,
|
|
153
|
-
error: ''
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
return {
|
|
157
|
-
valid: SyntaxValidationResult.Drop,
|
|
158
|
-
node: atRule,
|
|
159
|
-
syntax: null,
|
|
160
|
-
error: 'unknown at-rule'
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
const syntax = getParsedSyntax("atRules" /* ValidationSyntaxGroupEnum.AtRules */, name)?.[0];
|
|
164
|
-
if ('chi' in syntax && !('chi' in atRule)) {
|
|
165
|
-
return {
|
|
166
|
-
valid: SyntaxValidationResult.Drop,
|
|
167
|
-
node: atRule,
|
|
168
|
-
syntax,
|
|
169
|
-
error: 'missing at-rule body'
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
// if ('prelude' in syntax) {
|
|
173
|
-
//
|
|
174
|
-
// return validateSyntax(syntax.prelude as ValidationToken[], atRule.tokens as Token[], root, options);
|
|
175
|
-
// }
|
|
176
|
-
return {
|
|
177
|
-
valid: SyntaxValidationResult.Valid,
|
|
178
|
-
node: null,
|
|
179
|
-
syntax,
|
|
180
|
-
error: ''
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export { validateAtRule };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { EnumToken } from '../ast/types.js';
|
|
2
|
-
import '../ast/minify.js';
|
|
3
|
-
import '../ast/walk.js';
|
|
4
|
-
import '../parser/parse.js';
|
|
5
|
-
import '../parser/tokenize.js';
|
|
6
|
-
import '../parser/utils/config.js';
|
|
7
|
-
import '../syntax/color/utils/constants.js';
|
|
8
|
-
import '../renderer/sourcemap/lib/encode.js';
|
|
9
|
-
import { validateRelativeSelectorList } from './syntaxes/relative-selector-list.js';
|
|
10
|
-
import './syntaxes/complex-selector.js';
|
|
11
|
-
import './syntax.js';
|
|
12
|
-
import './config.js';
|
|
13
|
-
import { validateSelectorList } from './syntaxes/selector-list.js';
|
|
14
|
-
|
|
15
|
-
function validateSelector(selector, options, root) {
|
|
16
|
-
let isNested = root.typ == EnumToken.RuleNodeType ? 1 : 0;
|
|
17
|
-
let currentRoot = root.parent;
|
|
18
|
-
while (currentRoot != null && isNested == 0) {
|
|
19
|
-
if (currentRoot.typ == EnumToken.RuleNodeType) {
|
|
20
|
-
isNested++;
|
|
21
|
-
if (isNested > 0) {
|
|
22
|
-
// @ts-ignore
|
|
23
|
-
return validateRelativeSelectorList(selector, root, { ...(options ?? {}), nestedSelector: true });
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
currentRoot = currentRoot.parent;
|
|
27
|
-
}
|
|
28
|
-
const nestedSelector = isNested > 0;
|
|
29
|
-
// @ts-ignore
|
|
30
|
-
return nestedSelector ? validateRelativeSelectorList(selector, root, {
|
|
31
|
-
...(options ?? {}),
|
|
32
|
-
nestedSelector
|
|
33
|
-
}) : validateSelectorList(selector, root, { ...(options ?? {}), nestedSelector });
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { validateSelector };
|