UNPKG

2.75 kBTypeScriptView Raw
1// Type definitions for sizzle 2.3
2// Project: https://sizzlejs.com
3// Definitions by: Leonard Thieu <https://github.com/leonard-thieu>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5// TypeScript Version: 2.3
6
7export as namespace Sizzle;
8
9declare const Sizzle: SizzleStatic;
10export = Sizzle;
11
12interface SizzleStatic {
13 selectors: Sizzle.Selectors;
14 <TArrayLike extends ArrayLike<Element>>(selector: string, context: Element | Document | DocumentFragment, results: TArrayLike): TArrayLike;
15 (selector: string, context?: Element | Document | DocumentFragment): Element[];
16 // tslint:disable-next-line:ban-types
17 compile(selector: string): Function;
18 matchesSelector(element: Element, selector: string): boolean;
19 matches(selector: string, elements: Element[]): Element[];
20}
21
22declare namespace Sizzle {
23 interface Selectors {
24 cacheLength: number;
25 match: Selectors.Matches;
26 find: Selectors.FindFunctions;
27 preFilter: Selectors.PreFilterFunctions;
28 filter: Selectors.FilterFunctions;
29 attrHandle: Selectors.AttrHandleFunctions;
30 pseudos: Selectors.PseudoFunctions;
31 setFilters: Selectors.SetFilterFunctions;
32 createPseudo(fn: Selectors.CreatePseudoFunction): Selectors.PseudoFunction;
33 }
34
35 namespace Selectors {
36 interface Matches {
37 [name: string]: RegExp;
38 }
39
40 interface FindFunction {
41 (match: RegExpMatchArray, context: Element | Document, isXML: boolean): Element[] | void;
42 }
43
44 interface FindFunctions {
45 [name: string]: FindFunction;
46 }
47
48 interface PreFilterFunction {
49 (match: RegExpMatchArray): string[];
50 }
51
52 interface PreFilterFunctions {
53 [name: string]: PreFilterFunction;
54 }
55
56 interface FilterFunction {
57 (element: string, ...matches: string[]): boolean;
58 }
59
60 interface FilterFunctions {
61 [name: string]: FilterFunction;
62 }
63
64 interface AttrHandleFunction {
65 (elem: any, casePreservedName: string, isXML: boolean): string;
66 }
67
68 interface AttrHandleFunctions {
69 [name: string]: AttrHandleFunction;
70 }
71
72 interface PseudoFunction {
73 (elem: Element): boolean;
74 }
75
76 interface PseudoFunctions {
77 [name: string]: PseudoFunction;
78 }
79
80 interface SetFilterFunction {
81 (elements: Element[], argument: number, not: boolean): Element[];
82 }
83
84 interface SetFilterFunctions {
85 [name: string]: SetFilterFunction;
86 }
87
88 interface CreatePseudoFunction {
89 (...args: any[]): PseudoFunction;
90 }
91 }
92}