UNPKG

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