Interface FindParentOptions

Options for findParentElement. The most common options are use of FindParentOptions.stackingContext and / or the exclusion CSS class / ID properties such as ElementMatchesOptions.excludeClasses.

interface FindParentOptions {
    excludeClasses?: Iterable<string>;
    excludeIds?: Iterable<string>;
    excludeSelector?: string;
    includeClasses?: Iterable<string>;
    includeIds?: Iterable<string>;
    maxDepth?: number;
    predicate?: (el: Element) => boolean;
    selector?: string;
    stackingContext?: boolean;
    stopAt?: Element;
}
Hierarchy
Index
excludeClasses?: Iterable<string>

Iterable list of CSS classes which disqualify an element.

excludeIds?: Iterable<string>

Iterable list of IDs which disqualify an element.

excludeSelector?: string

CSS selector which disqualifies an element if matched.

includeClasses?: Iterable<string>

Iterable list of CSS classes an element must contain to be accepted.

includeIds?: Iterable<string>

Iterable list of IDs an element must have to be accepted.

maxDepth?: number

Positive integer defining maximum number of parentElement hops allowed.

predicate?: (el: Element) => boolean

Custom predicate; must return true for an element to be accepted.

selector?: string

CSS selector an ancestor must match to be accepted.

stackingContext?: boolean

When true, traverse parent elements until the stacking context element is found. The stacking context element will be evaluated against any filter criteria such as inclusion / exclusion rules. If it passes the filter then it is returned otherwise the next stacking context element is evaluated.

This option overrides stopAt and maxDepth options.

stopAt?: Element

Stops traversal when this element is reached.

The element itself will still be evaluated against any filter criteria such as inclusion / exclusion rules. If it passes the filter then it is returned. If it does not pass then null is returned.