parse.d.ts
2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
export interface Options {
/**
* When false, tag names will not be lowercased.
* @default true
*/
lowerCaseAttributeNames?: boolean;
/**
* When false, attribute names will not be lowercased.
* @default true
*/
lowerCaseTags?: boolean;
/**
* When `true`, `xmlMode` implies both `lowerCaseTags` and `lowerCaseAttributeNames` are set to `false`.
* Also, `ignoreCase` on attributes will not be inferred based on HTML rules anymore.
* @default false
*/
xmlMode?: boolean;
}
export declare type Selector = PseudoSelector | PseudoElement | AttributeSelector | TagSelector | UniversalSelector | Traversal;
export interface AttributeSelector {
type: "attribute";
name: string;
action: AttributeAction;
value: string;
ignoreCase: boolean | null;
namespace: string | null;
}
declare type DataType = Selector[][] | null | string;
export interface PseudoSelector {
type: "pseudo";
name: string;
data: DataType;
}
export interface PseudoElement {
type: "pseudo-element";
name: string;
}
export interface TagSelector {
type: "tag";
name: string;
namespace: string | null;
}
export interface UniversalSelector {
type: "universal";
namespace: string | null;
}
export interface Traversal {
type: TraversalType;
}
export declare type AttributeAction = "any" | "element" | "end" | "equals" | "exists" | "hyphen" | "not" | "start";
export declare type TraversalType = "adjacent" | "child" | "descendant" | "parent" | "sibling";
/**
* Checks whether a specific selector is a traversal.
* This is useful eg. in swapping the order of elements that
* are not traversals.
*
* @param selector Selector to check.
*/
export declare function isTraversal(selector: Selector): selector is Traversal;
/**
* Parses `selector`, optionally with the passed `options`.
*
* @param selector Selector to parse.
* @param options Options for parsing.
* @returns Returns a two-dimensional array.
* The first dimension represents selectors separated by commas (eg. `sub1, sub2`),
* the second contains the relevant tokens for that selector.
*/
export default function parse(selector: string, options?: Options): Selector[][];
export {};
//# sourceMappingURL=parse.d.ts.map