UNPKG

2.27 kBTypeScriptView Raw
1import { AnyNode, ChildNode, Element, ParentNode } from "domhandler";
2/**
3 * Get a node's children.
4 *
5 * @category Traversal
6 * @param elem Node to get the children of.
7 * @returns `elem`'s children, or an empty array.
8 */
9export declare function getChildren(elem: AnyNode): ChildNode[];
10export declare function getParent(elem: AnyNode): ParentNode | null;
11/**
12 * Gets an elements siblings, including the element itself.
13 *
14 * Attempts to get the children through the element's parent first. If we don't
15 * have a parent (the element is a root node), we walk the element's `prev` &
16 * `next` to get all remaining nodes.
17 *
18 * @category Traversal
19 * @param elem Element to get the siblings of.
20 * @returns `elem`'s siblings, including `elem`.
21 */
22export declare function getSiblings(elem: AnyNode): AnyNode[];
23/**
24 * Gets an attribute from an element.
25 *
26 * @category Traversal
27 * @param elem Element to check.
28 * @param name Attribute name to retrieve.
29 * @returns The element's attribute value, or `undefined`.
30 */
31export declare function getAttributeValue(elem: Element, name: string): string | undefined;
32/**
33 * Checks whether an element has an attribute.
34 *
35 * @category Traversal
36 * @param elem Element to check.
37 * @param name Attribute name to look for.
38 * @returns Returns whether `elem` has the attribute `name`.
39 */
40export declare function hasAttrib(elem: Element, name: string): boolean;
41/**
42 * Get the tag name of an element.
43 *
44 * @category Traversal
45 * @param elem The element to get the name for.
46 * @returns The tag name of `elem`.
47 */
48export declare function getName(elem: Element): string;
49/**
50 * Returns the next element sibling of a node.
51 *
52 * @category Traversal
53 * @param elem The element to get the next sibling of.
54 * @returns `elem`'s next sibling that is a tag, or `null` if there is no next
55 * sibling.
56 */
57export declare function nextElementSibling(elem: AnyNode): Element | null;
58/**
59 * Returns the previous element sibling of a node.
60 *
61 * @category Traversal
62 * @param elem The element to get the previous sibling of.
63 * @returns `elem`'s previous sibling that is a tag, or `null` if there is no
64 * previous sibling.
65 */
66export declare function prevElementSibling(elem: AnyNode): Element | null;
67//# sourceMappingURL=traversal.d.ts.map
\No newline at end of file