Project

General

Profile

1
/**
2
 * A css selector contains an element name,
3
 * css classes and attribute/value pairs with the purpose
4
 * of selecting subsets out of them.
5
 */
6
export declare class CssSelector {
7
    element: string | null;
8
    classNames: string[];
9
    attrs: string[];
10
    notSelectors: CssSelector[];
11
    static parse(selector: string): CssSelector[];
12
    isElementSelector(): boolean;
13
    hasElementSelector(): boolean;
14
    setElement(element?: string | null): void;
15
    /** Gets a template string for an element that matches the selector. */
16
    getMatchingElementTemplate(): string;
17
    addAttribute(name: string, value?: string): void;
18
    addClassName(name: string): void;
19
    toString(): string;
20
}
21
/**
22
 * Reads a list of CssSelectors and allows to calculate which ones
23
 * are contained in a given CssSelector.
24
 */
25
export declare class SelectorMatcher {
26
    static createNotMatcher(notSelectors: CssSelector[]): SelectorMatcher;
27
    private _elementMap;
28
    private _elementPartialMap;
29
    private _classMap;
30
    private _classPartialMap;
31
    private _attrValueMap;
32
    private _attrValuePartialMap;
33
    private _listContexts;
34
    addSelectables(cssSelectors: CssSelector[], callbackCtxt?: any): void;
35
    /**
36
     * Add an object that can be found later on by calling `match`.
37
     * @param cssSelector A css selector
38
     * @param callbackCtxt An opaque object that will be given to the callback of the `match` function
39
     */
40
    private _addSelectable(cssSelector, callbackCtxt, listContext);
41
    private _addTerminal(map, name, selectable);
42
    private _addPartial(map, name);
43
    /**
44
     * Find the objects that have been added via `addSelectable`
45
     * whose css selector is contained in the given css selector.
46
     * @param cssSelector A css selector
47
     * @param matchedCallback This callback will be called with the object handed into `addSelectable`
48
     * @return boolean true if a match was found
49
    */
50
    match(cssSelector: CssSelector, matchedCallback: ((c: CssSelector, a: any) => void) | null): boolean;
51
}
52
export declare class SelectorListContext {
53
    selectors: CssSelector[];
54
    alreadyMatched: boolean;
55
    constructor(selectors: CssSelector[]);
56
}
57
export declare class SelectorContext {
58
    selector: CssSelector;
59
    cbContext: any;
60
    listContext: SelectorListContext;
61
    notSelectors: CssSelector[];
62
    constructor(selector: CssSelector, cbContext: any, listContext: SelectorListContext);
63
    finalize(cssSelector: CssSelector, callback: ((c: CssSelector, a: any) => void) | null): boolean;
64
}
(39-39/54)