UNPKG

1.78 kBTypeScriptView Raw
1/**
2 * Given a child DOM element, returns a query-selector statement describing that
3 * and its ancestors
4 * e.g. [HTMLElement] => body > div > input#foo.btn[name=baz]
5 * @returns generated DOM path
6 */
7export declare function htmlTreeAsString(elem: unknown, options?: string[] | {
8 keyAttrs?: string[];
9 maxStringLength?: number;
10}): string;
11/**
12 * A safe form of location.href
13 */
14export declare function getLocationHref(): string;
15/**
16 * Gets a DOM element by using document.querySelector.
17 *
18 * This wrapper will first check for the existance of the function before
19 * actually calling it so that we don't have to take care of this check,
20 * every time we want to access the DOM.
21 *
22 * Reason: DOM/querySelector is not available in all environments.
23 *
24 * We have to cast to any because utils can be consumed by a variety of environments,
25 * and we don't want to break TS users. If you know what element will be selected by
26 * `document.querySelector`, specify it as part of the generic call. For example,
27 * `const element = getDomElement<Element>('selector');`
28 *
29 * @param selector the selector string passed on to document.querySelector
30 */
31export declare function getDomElement<E = any>(selector: string): E | null;
32/**
33 * Given a DOM element, traverses up the tree until it finds the first ancestor node
34 * that has the `data-sentry-component` or `data-sentry-element` attribute with `data-sentry-component` taking
35 * precendence. This attribute is added at build-time by projects that have the component name annotation plugin installed.
36 *
37 * @returns a string representation of the component for the provided DOM element, or `null` if not found
38 */
39export declare function getComponentName(elem: unknown): string | null;
40//# sourceMappingURL=browser.d.ts.map
\No newline at end of file