UNPKG

@augment-vir/web

Version:

A collection of augments, helpers types, functions, and classes only for web (frontend) JavaScript environments.

55 lines (54 loc) 2.44 kB
/** * Gets all deeply nested elements contained within the given element, flattened into a single * array. Shadow DOMs are traversed. * * Note that `<slot>` elements are included, as well as their nested elements (even if a slot filler * is provided by the parent) and the slot filler itself (if provided). * * Optionally define a second "depth" input to control how far nestings should be pursued. Omit * depth or set it to `undefined` or `0` to allow full depth search. * * @category Web : Elements * @category Package : @augment-vir/web * @package [`@augment-vir/web`](https://www.npmjs.com/package/@augment-vir/web) */ export declare function getNestedChildren(startingElement: Readonly<Element>, depth?: number | undefined): Element[]; /** * A tree of child elements. * * @category Web : Elements * @category Package : @augment-vir/web * @package [`@augment-vir/web`](https://www.npmjs.com/package/@augment-vir/web) */ export type ElementTree = { element: Element; children: ElementTree[]; }; /** * Gets all deeply nested elements contained within the given element in a tree. Shadow DOMs are * traversed. * * Note that `<slot>` elements are included, as well as their nested elements (even if a slot filler * is provided by the parent) and the slot filler itself (if provided). * * Optionally define a second "depth" input to control how far nestings should be pursued. Omit * depth or set it to `undefined` or `0` to allow full depth search. * * @category Web : Elements * @category Package : @augment-vir/web * @package [`@augment-vir/web`](https://www.npmjs.com/package/@augment-vir/web) */ export declare function getNestedChildrenTree(startingElement: Readonly<Element>, depth?: number | undefined): ElementTree; /** * Gets an element's direct children. Includes slotted elements, direct `<slot>` children * themselves, and all direct children of a shadow DOM. Default `<slot>` children are not included * (since they're not "direct" children as they are nested under `<slot>`). * * Note that that slotted elements and light dom elements will always be shown above shadow dom * elements. Besides that, the order of children is preserved. * * @category Web : Elements * @category Package : @augment-vir/web * @package [`@augment-vir/web`](https://www.npmjs.com/package/@augment-vir/web) */ export declare function getDirectChildren(startingElement: Readonly<Element>): Element[];