@eslint/css-tree 3.2.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.
- package/LICENSE +20 -0
- package/README.md +194 -0
- package/cjs/convertor/create.cjs +32 -0
- package/cjs/convertor/index.cjs +8 -0
- package/cjs/data-patch.cjs +7 -0
- package/cjs/data.cjs +120 -0
- package/cjs/definition-syntax/SyntaxError.cjs +16 -0
- package/cjs/definition-syntax/generate.cjs +139 -0
- package/cjs/definition-syntax/index.cjs +13 -0
- package/cjs/definition-syntax/parse.cjs +556 -0
- package/cjs/definition-syntax/scanner.cjs +113 -0
- package/cjs/definition-syntax/walk.cjs +57 -0
- package/cjs/generator/create.cjs +102 -0
- package/cjs/generator/index.cjs +8 -0
- package/cjs/generator/sourceMap.cjs +96 -0
- package/cjs/generator/token-before.cjs +170 -0
- package/cjs/index.cjs +65 -0
- package/cjs/lexer/Lexer.cjs +517 -0
- package/cjs/lexer/error.cjs +128 -0
- package/cjs/lexer/generic-an-plus-b.cjs +235 -0
- package/cjs/lexer/generic-const.cjs +12 -0
- package/cjs/lexer/generic-urange.cjs +149 -0
- package/cjs/lexer/generic.cjs +589 -0
- package/cjs/lexer/index.cjs +7 -0
- package/cjs/lexer/match-graph.cjs +530 -0
- package/cjs/lexer/match.cjs +632 -0
- package/cjs/lexer/prepare-tokens.cjs +54 -0
- package/cjs/lexer/search.cjs +65 -0
- package/cjs/lexer/structure.cjs +173 -0
- package/cjs/lexer/trace.cjs +73 -0
- package/cjs/lexer/units.cjs +38 -0
- package/cjs/parser/SyntaxError.cjs +74 -0
- package/cjs/parser/create.cjs +378 -0
- package/cjs/parser/index.cjs +8 -0
- package/cjs/parser/parse-selector.cjs +8 -0
- package/cjs/parser/sequence.cjs +47 -0
- package/cjs/syntax/atrule/container.cjs +32 -0
- package/cjs/syntax/atrule/font-face.cjs +12 -0
- package/cjs/syntax/atrule/import.cjs +101 -0
- package/cjs/syntax/atrule/index.cjs +27 -0
- package/cjs/syntax/atrule/layer.cjs +16 -0
- package/cjs/syntax/atrule/media.cjs +16 -0
- package/cjs/syntax/atrule/nest.cjs +16 -0
- package/cjs/syntax/atrule/page.cjs +16 -0
- package/cjs/syntax/atrule/scope.cjs +16 -0
- package/cjs/syntax/atrule/starting-style.cjs +12 -0
- package/cjs/syntax/atrule/supports.cjs +16 -0
- package/cjs/syntax/config/generator.cjs +9 -0
- package/cjs/syntax/config/lexer.cjs +14 -0
- package/cjs/syntax/config/mix.cjs +126 -0
- package/cjs/syntax/config/parser-selector.cjs +19 -0
- package/cjs/syntax/config/parser.cjs +49 -0
- package/cjs/syntax/config/walker.cjs +9 -0
- package/cjs/syntax/create.cjs +58 -0
- package/cjs/syntax/function/expression.cjs +11 -0
- package/cjs/syntax/function/var.cjs +43 -0
- package/cjs/syntax/index.cjs +14 -0
- package/cjs/syntax/node/AnPlusB.cjs +293 -0
- package/cjs/syntax/node/Atrule.cjs +103 -0
- package/cjs/syntax/node/AtrulePrelude.cjs +52 -0
- package/cjs/syntax/node/AttributeSelector.cjs +148 -0
- package/cjs/syntax/node/Block.cjs +96 -0
- package/cjs/syntax/node/Brackets.cjs +38 -0
- package/cjs/syntax/node/CDC.cjs +26 -0
- package/cjs/syntax/node/CDO.cjs +26 -0
- package/cjs/syntax/node/ClassSelector.cjs +31 -0
- package/cjs/syntax/node/Combinator.cjs +61 -0
- package/cjs/syntax/node/Comment.cjs +40 -0
- package/cjs/syntax/node/Condition.cjs +120 -0
- package/cjs/syntax/node/Declaration.cjs +166 -0
- package/cjs/syntax/node/DeclarationList.cjs +62 -0
- package/cjs/syntax/node/Dimension.cjs +30 -0
- package/cjs/syntax/node/Feature.cjs +101 -0
- package/cjs/syntax/node/FeatureFunction.cjs +67 -0
- package/cjs/syntax/node/FeatureRange.cjs +133 -0
- package/cjs/syntax/node/Function.cjs +45 -0
- package/cjs/syntax/node/GeneralEnclosed.cjs +68 -0
- package/cjs/syntax/node/Hash.cjs +30 -0
- package/cjs/syntax/node/IdSelector.cjs +33 -0
- package/cjs/syntax/node/Identifier.cjs +25 -0
- package/cjs/syntax/node/Layer.cjs +35 -0
- package/cjs/syntax/node/LayerList.cjs +43 -0
- package/cjs/syntax/node/MediaQuery.cjs +100 -0
- package/cjs/syntax/node/MediaQueryList.cjs +41 -0
- package/cjs/syntax/node/NestingSelector.cjs +29 -0
- package/cjs/syntax/node/Nth.cjs +54 -0
- package/cjs/syntax/node/Number.cjs +25 -0
- package/cjs/syntax/node/Operator.cjs +28 -0
- package/cjs/syntax/node/Parentheses.cjs +38 -0
- package/cjs/syntax/node/Percentage.cjs +25 -0
- package/cjs/syntax/node/PseudoClassSelector.cjs +67 -0
- package/cjs/syntax/node/PseudoElementSelector.cjs +69 -0
- package/cjs/syntax/node/Ratio.cjs +71 -0
- package/cjs/syntax/node/Raw.cjs +48 -0
- package/cjs/syntax/node/Rule.cjs +58 -0
- package/cjs/syntax/node/Scope.cjs +69 -0
- package/cjs/syntax/node/Selector.cjs +38 -0
- package/cjs/syntax/node/SelectorList.cjs +43 -0
- package/cjs/syntax/node/String.cjs +26 -0
- package/cjs/syntax/node/StyleSheet.cjs +83 -0
- package/cjs/syntax/node/SupportsDeclaration.cjs +38 -0
- package/cjs/syntax/node/TypeSelector.cjs +59 -0
- package/cjs/syntax/node/UnicodeRange.cjs +158 -0
- package/cjs/syntax/node/Url.cjs +54 -0
- package/cjs/syntax/node/Value.cjs +26 -0
- package/cjs/syntax/node/WhiteSpace.cjs +34 -0
- package/cjs/syntax/node/index-generate.cjs +103 -0
- package/cjs/syntax/node/index-parse-selector.cjs +39 -0
- package/cjs/syntax/node/index-parse.cjs +103 -0
- package/cjs/syntax/node/index.cjs +103 -0
- package/cjs/syntax/pseudo/index.cjs +60 -0
- package/cjs/syntax/pseudo/lang.cjs +37 -0
- package/cjs/syntax/scope/atrulePrelude.cjs +9 -0
- package/cjs/syntax/scope/default.cjs +76 -0
- package/cjs/syntax/scope/index.cjs +11 -0
- package/cjs/syntax/scope/selector.cjs +88 -0
- package/cjs/syntax/scope/value.cjs +29 -0
- package/cjs/tokenizer/OffsetToLocation.cjs +91 -0
- package/cjs/tokenizer/TokenStream.cjs +358 -0
- package/cjs/tokenizer/adopt-buffer.cjs +13 -0
- package/cjs/tokenizer/char-code-definitions.cjs +236 -0
- package/cjs/tokenizer/index.cjs +554 -0
- package/cjs/tokenizer/names.cjs +32 -0
- package/cjs/tokenizer/types.cjs +57 -0
- package/cjs/tokenizer/utils.cjs +261 -0
- package/cjs/utils/List.cjs +473 -0
- package/cjs/utils/clone.cjs +25 -0
- package/cjs/utils/create-custom-error.cjs +18 -0
- package/cjs/utils/ident.cjs +102 -0
- package/cjs/utils/index.cjs +20 -0
- package/cjs/utils/names.cjs +113 -0
- package/cjs/utils/string.cjs +99 -0
- package/cjs/utils/url.cjs +108 -0
- package/cjs/version.cjs +5 -0
- package/cjs/walker/create.cjs +291 -0
- package/cjs/walker/index.cjs +8 -0
- package/data/patch.json +874 -0
- package/dist/csstree.esm.js +12 -0
- package/dist/csstree.js +12 -0
- package/dist/data.cjs +1341 -0
- package/dist/data.js +1341 -0
- package/dist/version.cjs +1 -0
- package/dist/version.js +1 -0
- package/lib/convertor/create.js +28 -0
- package/lib/convertor/index.js +4 -0
- package/lib/data-patch.js +6 -0
- package/lib/data.js +118 -0
- package/lib/definition-syntax/SyntaxError.js +12 -0
- package/lib/definition-syntax/generate.js +135 -0
- package/lib/definition-syntax/index.js +4 -0
- package/lib/definition-syntax/parse.js +552 -0
- package/lib/definition-syntax/scanner.js +109 -0
- package/lib/definition-syntax/walk.js +53 -0
- package/lib/generator/create.js +97 -0
- package/lib/generator/index.js +4 -0
- package/lib/generator/sourceMap.js +92 -0
- package/lib/generator/token-before.js +182 -0
- package/lib/index.d.ts +3016 -0
- package/lib/index.js +30 -0
- package/lib/lexer/Lexer.js +511 -0
- package/lib/lexer/error.js +123 -0
- package/lib/lexer/generic-an-plus-b.js +238 -0
- package/lib/lexer/generic-const.js +8 -0
- package/lib/lexer/generic-urange.js +151 -0
- package/lib/lexer/generic.js +622 -0
- package/lib/lexer/index.js +1 -0
- package/lib/lexer/match-graph.js +527 -0
- package/lib/lexer/match.js +630 -0
- package/lib/lexer/prepare-tokens.js +50 -0
- package/lib/lexer/search.js +61 -0
- package/lib/lexer/structure.js +169 -0
- package/lib/lexer/trace.js +66 -0
- package/lib/lexer/units.js +27 -0
- package/lib/parser/SyntaxError.js +70 -0
- package/lib/parser/create.js +388 -0
- package/lib/parser/index.js +4 -0
- package/lib/parser/parse-selector.js +4 -0
- package/lib/parser/sequence.js +43 -0
- package/lib/syntax/atrule/container.js +28 -0
- package/lib/syntax/atrule/font-face.js +8 -0
- package/lib/syntax/atrule/import.js +104 -0
- package/lib/syntax/atrule/index.js +23 -0
- package/lib/syntax/atrule/layer.js +12 -0
- package/lib/syntax/atrule/media.js +12 -0
- package/lib/syntax/atrule/nest.js +12 -0
- package/lib/syntax/atrule/page.js +12 -0
- package/lib/syntax/atrule/scope.js +12 -0
- package/lib/syntax/atrule/starting-style.js +8 -0
- package/lib/syntax/atrule/supports.js +12 -0
- package/lib/syntax/config/generator.js +5 -0
- package/lib/syntax/config/lexer.js +10 -0
- package/lib/syntax/config/mix.js +122 -0
- package/lib/syntax/config/parser-selector.js +15 -0
- package/lib/syntax/config/parser.js +45 -0
- package/lib/syntax/config/walker.js +5 -0
- package/lib/syntax/create.js +55 -0
- package/lib/syntax/function/expression.js +7 -0
- package/lib/syntax/function/var.js +39 -0
- package/lib/syntax/index.js +10 -0
- package/lib/syntax/node/AnPlusB.js +292 -0
- package/lib/syntax/node/Atrule.js +100 -0
- package/lib/syntax/node/AtrulePrelude.js +47 -0
- package/lib/syntax/node/AttributeSelector.js +147 -0
- package/lib/syntax/node/Block.js +95 -0
- package/lib/syntax/node/Brackets.js +35 -0
- package/lib/syntax/node/CDC.js +19 -0
- package/lib/syntax/node/CDO.js +19 -0
- package/lib/syntax/node/ClassSelector.js +24 -0
- package/lib/syntax/node/Combinator.js +54 -0
- package/lib/syntax/node/Comment.js +33 -0
- package/lib/syntax/node/Condition.js +123 -0
- package/lib/syntax/node/Declaration.js +165 -0
- package/lib/syntax/node/DeclarationList.js +62 -0
- package/lib/syntax/node/Dimension.js +23 -0
- package/lib/syntax/node/Feature.js +103 -0
- package/lib/syntax/node/FeatureFunction.js +63 -0
- package/lib/syntax/node/FeatureRange.js +133 -0
- package/lib/syntax/node/Function.js +41 -0
- package/lib/syntax/node/GeneralEnclosed.js +66 -0
- package/lib/syntax/node/Hash.js +23 -0
- package/lib/syntax/node/IdSelector.js +26 -0
- package/lib/syntax/node/Identifier.js +18 -0
- package/lib/syntax/node/Layer.js +28 -0
- package/lib/syntax/node/LayerList.js +36 -0
- package/lib/syntax/node/MediaQuery.js +102 -0
- package/lib/syntax/node/MediaQueryList.js +34 -0
- package/lib/syntax/node/NestingSelector.js +22 -0
- package/lib/syntax/node/Nth.js +47 -0
- package/lib/syntax/node/Number.js +18 -0
- package/lib/syntax/node/Operator.js +21 -0
- package/lib/syntax/node/Parentheses.js +34 -0
- package/lib/syntax/node/Percentage.js +18 -0
- package/lib/syntax/node/PseudoClassSelector.js +65 -0
- package/lib/syntax/node/PseudoElementSelector.js +66 -0
- package/lib/syntax/node/Ratio.js +68 -0
- package/lib/syntax/node/Raw.js +41 -0
- package/lib/syntax/node/Rule.js +51 -0
- package/lib/syntax/node/Scope.js +66 -0
- package/lib/syntax/node/Selector.js +31 -0
- package/lib/syntax/node/SelectorList.js +35 -0
- package/lib/syntax/node/String.js +19 -0
- package/lib/syntax/node/StyleSheet.js +82 -0
- package/lib/syntax/node/SupportsDeclaration.js +34 -0
- package/lib/syntax/node/TypeSelector.js +52 -0
- package/lib/syntax/node/UnicodeRange.js +156 -0
- package/lib/syntax/node/Url.js +52 -0
- package/lib/syntax/node/Value.js +19 -0
- package/lib/syntax/node/WhiteSpace.js +27 -0
- package/lib/syntax/node/index-generate.js +49 -0
- package/lib/syntax/node/index-parse-selector.js +17 -0
- package/lib/syntax/node/index-parse.js +49 -0
- package/lib/syntax/node/index.js +49 -0
- package/lib/syntax/pseudo/index.js +56 -0
- package/lib/syntax/pseudo/lang.js +33 -0
- package/lib/syntax/scope/atrulePrelude.js +5 -0
- package/lib/syntax/scope/default.js +85 -0
- package/lib/syntax/scope/index.js +3 -0
- package/lib/syntax/scope/selector.js +94 -0
- package/lib/syntax/scope/value.js +25 -0
- package/lib/tokenizer/OffsetToLocation.js +87 -0
- package/lib/tokenizer/TokenStream.js +366 -0
- package/lib/tokenizer/adopt-buffer.js +9 -0
- package/lib/tokenizer/char-code-definitions.js +212 -0
- package/lib/tokenizer/index.js +513 -0
- package/lib/tokenizer/names.js +28 -0
- package/lib/tokenizer/types.js +28 -0
- package/lib/tokenizer/utils.js +254 -0
- package/lib/utils/List.js +469 -0
- package/lib/utils/clone.js +21 -0
- package/lib/utils/create-custom-error.js +14 -0
- package/lib/utils/ident.js +101 -0
- package/lib/utils/index.js +6 -0
- package/lib/utils/names.js +106 -0
- package/lib/utils/string.js +99 -0
- package/lib/utils/url.js +108 -0
- package/lib/version.js +5 -0
- package/lib/walker/create.js +287 -0
- package/lib/walker/index.js +4 -0
- package/package.json +133 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export { parse as AnPlusB } from './AnPlusB.js';
|
|
2
|
+
export { parse as Atrule } from './Atrule.js';
|
|
3
|
+
export { parse as AtrulePrelude } from './AtrulePrelude.js';
|
|
4
|
+
export { parse as AttributeSelector } from './AttributeSelector.js';
|
|
5
|
+
export { parse as Block } from './Block.js';
|
|
6
|
+
export { parse as Brackets } from './Brackets.js';
|
|
7
|
+
export { parse as CDC } from './CDC.js';
|
|
8
|
+
export { parse as CDO } from './CDO.js';
|
|
9
|
+
export { parse as ClassSelector } from './ClassSelector.js';
|
|
10
|
+
export { parse as Combinator } from './Combinator.js';
|
|
11
|
+
export { parse as Comment } from './Comment.js';
|
|
12
|
+
export { parse as Condition } from './Condition.js';
|
|
13
|
+
export { parse as Declaration } from './Declaration.js';
|
|
14
|
+
export { parse as DeclarationList } from './DeclarationList.js';
|
|
15
|
+
export { parse as Dimension } from './Dimension.js';
|
|
16
|
+
export { parse as Feature } from './Feature.js';
|
|
17
|
+
export { parse as FeatureFunction } from './FeatureFunction.js';
|
|
18
|
+
export { parse as FeatureRange } from './FeatureRange.js';
|
|
19
|
+
export { parse as Function } from './Function.js';
|
|
20
|
+
export { parse as GeneralEnclosed } from './GeneralEnclosed.js';
|
|
21
|
+
export { parse as Hash } from './Hash.js';
|
|
22
|
+
export { parse as Identifier } from './Identifier.js';
|
|
23
|
+
export { parse as IdSelector } from './IdSelector.js';
|
|
24
|
+
export { parse as Layer } from './Layer.js';
|
|
25
|
+
export { parse as LayerList } from './LayerList.js';
|
|
26
|
+
export { parse as MediaQuery } from './MediaQuery.js';
|
|
27
|
+
export { parse as MediaQueryList } from './MediaQueryList.js';
|
|
28
|
+
export { parse as NestingSelector } from './NestingSelector.js';
|
|
29
|
+
export { parse as Nth } from './Nth.js';
|
|
30
|
+
export { parse as Number } from './Number.js';
|
|
31
|
+
export { parse as Operator } from './Operator.js';
|
|
32
|
+
export { parse as Parentheses } from './Parentheses.js';
|
|
33
|
+
export { parse as Percentage } from './Percentage.js';
|
|
34
|
+
export { parse as PseudoClassSelector } from './PseudoClassSelector.js';
|
|
35
|
+
export { parse as PseudoElementSelector } from './PseudoElementSelector.js';
|
|
36
|
+
export { parse as Ratio } from './Ratio.js';
|
|
37
|
+
export { parse as Raw } from './Raw.js';
|
|
38
|
+
export { parse as Rule } from './Rule.js';
|
|
39
|
+
export { parse as Scope } from './Scope.js';
|
|
40
|
+
export { parse as Selector } from './Selector.js';
|
|
41
|
+
export { parse as SelectorList } from './SelectorList.js';
|
|
42
|
+
export { parse as String } from './String.js';
|
|
43
|
+
export { parse as StyleSheet } from './StyleSheet.js';
|
|
44
|
+
export { parse as SupportsDeclaration } from './SupportsDeclaration.js';
|
|
45
|
+
export { parse as TypeSelector } from './TypeSelector.js';
|
|
46
|
+
export { parse as UnicodeRange } from './UnicodeRange.js';
|
|
47
|
+
export { parse as Url } from './Url.js';
|
|
48
|
+
export { parse as Value } from './Value.js';
|
|
49
|
+
export { parse as WhiteSpace } from './WhiteSpace.js';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export * as AnPlusB from './AnPlusB.js';
|
|
2
|
+
export * as Atrule from './Atrule.js';
|
|
3
|
+
export * as AtrulePrelude from './AtrulePrelude.js';
|
|
4
|
+
export * as AttributeSelector from './AttributeSelector.js';
|
|
5
|
+
export * as Block from './Block.js';
|
|
6
|
+
export * as Brackets from './Brackets.js';
|
|
7
|
+
export * as CDC from './CDC.js';
|
|
8
|
+
export * as CDO from './CDO.js';
|
|
9
|
+
export * as ClassSelector from './ClassSelector.js';
|
|
10
|
+
export * as Combinator from './Combinator.js';
|
|
11
|
+
export * as Comment from './Comment.js';
|
|
12
|
+
export * as Condition from './Condition.js';
|
|
13
|
+
export * as Declaration from './Declaration.js';
|
|
14
|
+
export * as DeclarationList from './DeclarationList.js';
|
|
15
|
+
export * as Dimension from './Dimension.js';
|
|
16
|
+
export * as Feature from './Feature.js';
|
|
17
|
+
export * as FeatureFunction from './FeatureFunction.js';
|
|
18
|
+
export * as FeatureRange from './FeatureRange.js';
|
|
19
|
+
export * as Function from './Function.js';
|
|
20
|
+
export * as GeneralEnclosed from './GeneralEnclosed.js';
|
|
21
|
+
export * as Hash from './Hash.js';
|
|
22
|
+
export * as Identifier from './Identifier.js';
|
|
23
|
+
export * as IdSelector from './IdSelector.js';
|
|
24
|
+
export * as Layer from './Layer.js';
|
|
25
|
+
export * as LayerList from './LayerList.js';
|
|
26
|
+
export * as MediaQuery from './MediaQuery.js';
|
|
27
|
+
export * as MediaQueryList from './MediaQueryList.js';
|
|
28
|
+
export * as NestingSelector from './NestingSelector.js';
|
|
29
|
+
export * as Nth from './Nth.js';
|
|
30
|
+
export * as Number from './Number.js';
|
|
31
|
+
export * as Operator from './Operator.js';
|
|
32
|
+
export * as Parentheses from './Parentheses.js';
|
|
33
|
+
export * as Percentage from './Percentage.js';
|
|
34
|
+
export * as PseudoClassSelector from './PseudoClassSelector.js';
|
|
35
|
+
export * as PseudoElementSelector from './PseudoElementSelector.js';
|
|
36
|
+
export * as Ratio from './Ratio.js';
|
|
37
|
+
export * as Raw from './Raw.js';
|
|
38
|
+
export * as Rule from './Rule.js';
|
|
39
|
+
export * as Scope from './Scope.js';
|
|
40
|
+
export * as Selector from './Selector.js';
|
|
41
|
+
export * as SelectorList from './SelectorList.js';
|
|
42
|
+
export * as String from './String.js';
|
|
43
|
+
export * as StyleSheet from './StyleSheet.js';
|
|
44
|
+
export * as SupportsDeclaration from './SupportsDeclaration.js';
|
|
45
|
+
export * as TypeSelector from './TypeSelector.js';
|
|
46
|
+
export * as UnicodeRange from './UnicodeRange.js';
|
|
47
|
+
export * as Url from './Url.js';
|
|
48
|
+
export * as Value from './Value.js';
|
|
49
|
+
export * as WhiteSpace from './WhiteSpace.js';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { parseLanguageRangeList } from './lang.js';
|
|
2
|
+
|
|
3
|
+
const selectorList = {
|
|
4
|
+
parse() {
|
|
5
|
+
return this.createSingleNodeList(
|
|
6
|
+
this.SelectorList()
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const selector = {
|
|
12
|
+
parse() {
|
|
13
|
+
return this.createSingleNodeList(
|
|
14
|
+
this.Selector()
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const identList = {
|
|
20
|
+
parse() {
|
|
21
|
+
return this.createSingleNodeList(
|
|
22
|
+
this.Identifier()
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const langList = {
|
|
28
|
+
parse: parseLanguageRangeList
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const nth = {
|
|
32
|
+
parse() {
|
|
33
|
+
return this.createSingleNodeList(
|
|
34
|
+
this.Nth()
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default {
|
|
40
|
+
'dir': identList,
|
|
41
|
+
'has': selectorList,
|
|
42
|
+
'lang': langList,
|
|
43
|
+
'matches': selectorList,
|
|
44
|
+
'is': selectorList,
|
|
45
|
+
'-moz-any': selectorList,
|
|
46
|
+
'-webkit-any': selectorList,
|
|
47
|
+
'where': selectorList,
|
|
48
|
+
'not': selectorList,
|
|
49
|
+
'nth-child': nth,
|
|
50
|
+
'nth-last-child': nth,
|
|
51
|
+
'nth-last-of-type': nth,
|
|
52
|
+
'nth-of-type': nth,
|
|
53
|
+
'slotted': selector,
|
|
54
|
+
'host': selector,
|
|
55
|
+
'host-context': selector
|
|
56
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Comma, String as StringToken, Ident, RightParenthesis } from '../../tokenizer/index.js';
|
|
2
|
+
|
|
3
|
+
export function parseLanguageRangeList() {
|
|
4
|
+
const children = this.createList();
|
|
5
|
+
|
|
6
|
+
this.skipSC();
|
|
7
|
+
|
|
8
|
+
loop: while (!this.eof) {
|
|
9
|
+
switch (this.tokenType) {
|
|
10
|
+
case Ident:
|
|
11
|
+
children.push(this.Identifier());
|
|
12
|
+
break;
|
|
13
|
+
|
|
14
|
+
case StringToken:
|
|
15
|
+
children.push(this.String());
|
|
16
|
+
break;
|
|
17
|
+
|
|
18
|
+
case Comma:
|
|
19
|
+
children.push(this.Operator());
|
|
20
|
+
break;
|
|
21
|
+
|
|
22
|
+
case RightParenthesis:
|
|
23
|
+
break loop;
|
|
24
|
+
|
|
25
|
+
default:
|
|
26
|
+
this.error('Identifier, string or comma is expected');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this.skipSC();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return children;
|
|
33
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Ident,
|
|
3
|
+
String as StringToken,
|
|
4
|
+
Number as NumberToken,
|
|
5
|
+
Function as FunctionToken,
|
|
6
|
+
Url,
|
|
7
|
+
Hash,
|
|
8
|
+
Dimension,
|
|
9
|
+
Percentage,
|
|
10
|
+
LeftParenthesis,
|
|
11
|
+
LeftSquareBracket,
|
|
12
|
+
Comma,
|
|
13
|
+
Delim
|
|
14
|
+
} from '../../tokenizer/index.js';
|
|
15
|
+
|
|
16
|
+
const NUMBERSIGN = 0x0023; // U+0023 NUMBER SIGN (#)
|
|
17
|
+
const ASTERISK = 0x002A; // U+002A ASTERISK (*)
|
|
18
|
+
const PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
|
|
19
|
+
const HYPHENMINUS = 0x002D; // U+002D HYPHEN-MINUS (-)
|
|
20
|
+
const SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
|
|
21
|
+
const U = 0x0075; // U+0075 LATIN SMALL LETTER U (u)
|
|
22
|
+
|
|
23
|
+
export default function defaultRecognizer(context) {
|
|
24
|
+
switch (this.tokenType) {
|
|
25
|
+
case Hash:
|
|
26
|
+
return this.Hash();
|
|
27
|
+
|
|
28
|
+
case Comma:
|
|
29
|
+
return this.Operator();
|
|
30
|
+
|
|
31
|
+
case LeftParenthesis:
|
|
32
|
+
return this.Parentheses(this.readSequence, context.recognizer);
|
|
33
|
+
|
|
34
|
+
case LeftSquareBracket:
|
|
35
|
+
return this.Brackets(this.readSequence, context.recognizer);
|
|
36
|
+
|
|
37
|
+
case StringToken:
|
|
38
|
+
return this.String();
|
|
39
|
+
|
|
40
|
+
case Dimension:
|
|
41
|
+
return this.Dimension();
|
|
42
|
+
|
|
43
|
+
case Percentage:
|
|
44
|
+
return this.Percentage();
|
|
45
|
+
|
|
46
|
+
case NumberToken:
|
|
47
|
+
return this.Number();
|
|
48
|
+
|
|
49
|
+
case FunctionToken:
|
|
50
|
+
return this.cmpStr(this.tokenStart, this.tokenEnd, 'url(')
|
|
51
|
+
? this.Url()
|
|
52
|
+
: this.Function(this.readSequence, context.recognizer);
|
|
53
|
+
|
|
54
|
+
case Url:
|
|
55
|
+
return this.Url();
|
|
56
|
+
|
|
57
|
+
case Ident:
|
|
58
|
+
// check for unicode range, it should start with u+ or U+
|
|
59
|
+
if (this.cmpChar(this.tokenStart, U) &&
|
|
60
|
+
this.cmpChar(this.tokenStart + 1, PLUSSIGN)) {
|
|
61
|
+
return this.UnicodeRange();
|
|
62
|
+
} else {
|
|
63
|
+
return this.Identifier();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
case Delim: {
|
|
67
|
+
const code = this.charCodeAt(this.tokenStart);
|
|
68
|
+
|
|
69
|
+
if (code === SOLIDUS ||
|
|
70
|
+
code === ASTERISK ||
|
|
71
|
+
code === PLUSSIGN ||
|
|
72
|
+
code === HYPHENMINUS) {
|
|
73
|
+
return this.Operator(); // TODO: replace with Delim
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// TODO: produce a node with Delim node type
|
|
77
|
+
|
|
78
|
+
if (code === NUMBERSIGN) {
|
|
79
|
+
this.error('Hex or identifier is expected', this.tokenStart + 1);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Delim,
|
|
3
|
+
Ident,
|
|
4
|
+
Dimension,
|
|
5
|
+
Percentage,
|
|
6
|
+
Number as NumberToken,
|
|
7
|
+
Hash,
|
|
8
|
+
Colon,
|
|
9
|
+
LeftSquareBracket
|
|
10
|
+
} from '../../tokenizer/index.js';
|
|
11
|
+
|
|
12
|
+
const NUMBERSIGN = 0x0023; // U+0023 NUMBER SIGN (#)
|
|
13
|
+
const AMPERSAND = 0x0026; // U+0026 AMPERSAND (&)
|
|
14
|
+
const ASTERISK = 0x002A; // U+002A ASTERISK (*)
|
|
15
|
+
const PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
|
|
16
|
+
const SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
|
|
17
|
+
const FULLSTOP = 0x002E; // U+002E FULL STOP (.)
|
|
18
|
+
const GREATERTHANSIGN = 0x003E; // U+003E GREATER-THAN SIGN (>)
|
|
19
|
+
const VERTICALLINE = 0x007C; // U+007C VERTICAL LINE (|)
|
|
20
|
+
const TILDE = 0x007E; // U+007E TILDE (~)
|
|
21
|
+
|
|
22
|
+
function onWhiteSpace(next, children) {
|
|
23
|
+
if (children.last !== null && children.last.type !== 'Combinator' &&
|
|
24
|
+
next !== null && next.type !== 'Combinator') {
|
|
25
|
+
children.push({ // FIXME: this.Combinator() should be used instead
|
|
26
|
+
type: 'Combinator',
|
|
27
|
+
loc: null,
|
|
28
|
+
name: ' '
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getNode() {
|
|
34
|
+
switch (this.tokenType) {
|
|
35
|
+
case LeftSquareBracket:
|
|
36
|
+
return this.AttributeSelector();
|
|
37
|
+
|
|
38
|
+
case Hash:
|
|
39
|
+
return this.IdSelector();
|
|
40
|
+
|
|
41
|
+
case Colon:
|
|
42
|
+
if (this.lookupType(1) === Colon) {
|
|
43
|
+
return this.PseudoElementSelector();
|
|
44
|
+
} else {
|
|
45
|
+
return this.PseudoClassSelector();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
case Ident:
|
|
49
|
+
return this.TypeSelector();
|
|
50
|
+
|
|
51
|
+
case NumberToken:
|
|
52
|
+
case Percentage:
|
|
53
|
+
return this.Percentage();
|
|
54
|
+
|
|
55
|
+
case Dimension:
|
|
56
|
+
// throws when .123ident
|
|
57
|
+
if (this.charCodeAt(this.tokenStart) === FULLSTOP) {
|
|
58
|
+
this.error('Identifier is expected', this.tokenStart + 1);
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
|
|
62
|
+
case Delim: {
|
|
63
|
+
const code = this.charCodeAt(this.tokenStart);
|
|
64
|
+
|
|
65
|
+
switch (code) {
|
|
66
|
+
case PLUSSIGN:
|
|
67
|
+
case GREATERTHANSIGN:
|
|
68
|
+
case TILDE:
|
|
69
|
+
case SOLIDUS: // /deep/
|
|
70
|
+
return this.Combinator();
|
|
71
|
+
|
|
72
|
+
case FULLSTOP:
|
|
73
|
+
return this.ClassSelector();
|
|
74
|
+
|
|
75
|
+
case ASTERISK:
|
|
76
|
+
case VERTICALLINE:
|
|
77
|
+
return this.TypeSelector();
|
|
78
|
+
|
|
79
|
+
case NUMBERSIGN:
|
|
80
|
+
return this.IdSelector();
|
|
81
|
+
|
|
82
|
+
case AMPERSAND:
|
|
83
|
+
return this.NestingSelector();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export default {
|
|
92
|
+
onWhiteSpace,
|
|
93
|
+
getNode
|
|
94
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import getNode from './default.js';
|
|
2
|
+
import expressionFn from '../function/expression.js';
|
|
3
|
+
import varFn from '../function/var.js';
|
|
4
|
+
|
|
5
|
+
function isPlusMinusOperator(node) {
|
|
6
|
+
return (
|
|
7
|
+
node !== null &&
|
|
8
|
+
node.type === 'Operator' &&
|
|
9
|
+
(node.value[node.value.length - 1] === '-' || node.value[node.value.length - 1] === '+')
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
getNode,
|
|
15
|
+
onWhiteSpace(next, children) {
|
|
16
|
+
if (isPlusMinusOperator(next)) {
|
|
17
|
+
next.value = ' ' + next.value;
|
|
18
|
+
}
|
|
19
|
+
if (isPlusMinusOperator(children.last)) {
|
|
20
|
+
children.last.value += ' ';
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
'expression': expressionFn,
|
|
24
|
+
'var': varFn
|
|
25
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { adoptBuffer } from './adopt-buffer.js';
|
|
2
|
+
import { isBOM } from './char-code-definitions.js';
|
|
3
|
+
|
|
4
|
+
const N = 10;
|
|
5
|
+
const F = 12;
|
|
6
|
+
const R = 13;
|
|
7
|
+
|
|
8
|
+
function computeLinesAndColumns(host) {
|
|
9
|
+
const source = host.source;
|
|
10
|
+
const sourceLength = source.length;
|
|
11
|
+
const startOffset = source.length > 0 ? isBOM(source.charCodeAt(0)) : 0;
|
|
12
|
+
const lines = adoptBuffer(host.lines, sourceLength);
|
|
13
|
+
const columns = adoptBuffer(host.columns, sourceLength);
|
|
14
|
+
let line = host.startLine;
|
|
15
|
+
let column = host.startColumn;
|
|
16
|
+
|
|
17
|
+
for (let i = startOffset; i < sourceLength; i++) {
|
|
18
|
+
const code = source.charCodeAt(i);
|
|
19
|
+
|
|
20
|
+
lines[i] = line;
|
|
21
|
+
columns[i] = column++;
|
|
22
|
+
|
|
23
|
+
if (code === N || code === R || code === F) {
|
|
24
|
+
if (code === R && i + 1 < sourceLength && source.charCodeAt(i + 1) === N) {
|
|
25
|
+
i++;
|
|
26
|
+
lines[i] = line;
|
|
27
|
+
columns[i] = column;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
line++;
|
|
31
|
+
column = 1;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
lines[sourceLength] = line;
|
|
36
|
+
columns[sourceLength] = column;
|
|
37
|
+
|
|
38
|
+
host.lines = lines;
|
|
39
|
+
host.columns = columns;
|
|
40
|
+
host.computed = true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class OffsetToLocation {
|
|
44
|
+
constructor(source, startOffset, startLine, startColumn) {
|
|
45
|
+
this.setSource(source, startOffset, startLine, startColumn);
|
|
46
|
+
this.lines = null;
|
|
47
|
+
this.columns = null;
|
|
48
|
+
}
|
|
49
|
+
setSource(source = '', startOffset = 0, startLine = 1, startColumn = 1) {
|
|
50
|
+
this.source = source;
|
|
51
|
+
this.startOffset = startOffset;
|
|
52
|
+
this.startLine = startLine;
|
|
53
|
+
this.startColumn = startColumn;
|
|
54
|
+
this.computed = false;
|
|
55
|
+
}
|
|
56
|
+
getLocation(offset, filename) {
|
|
57
|
+
if (!this.computed) {
|
|
58
|
+
computeLinesAndColumns(this);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
source: filename,
|
|
63
|
+
offset: this.startOffset + offset,
|
|
64
|
+
line: this.lines[offset],
|
|
65
|
+
column: this.columns[offset]
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
getLocationRange(start, end, filename) {
|
|
69
|
+
if (!this.computed) {
|
|
70
|
+
computeLinesAndColumns(this);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
source: filename,
|
|
75
|
+
start: {
|
|
76
|
+
offset: this.startOffset + start,
|
|
77
|
+
line: this.lines[start],
|
|
78
|
+
column: this.columns[start]
|
|
79
|
+
},
|
|
80
|
+
end: {
|
|
81
|
+
offset: this.startOffset + end,
|
|
82
|
+
line: this.lines[end],
|
|
83
|
+
column: this.columns[end]
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
};
|