return _getChildren(element, 2 /* ClassName */, className)[0] || null;
}
exports.childByClass = childByClass;
- /**
- * Examines child elements and returns the first child which equals the given tag.
- */
function childByTag(element, tagName) {
return _getChildren(element, 3 /* TagName */, tagName)[0] || null;
}
return _getChildren(element, 2 /* ClassName */, className);
}
exports.childrenByClass = childrenByClass;
- /**
- * Examines child elements and returns all children which equal the given tag.
- */
function childrenByTag(element, tagName) {
return _getChildren(element, 3 /* TagName */, tagName);
}
/**
* Examines child elements and returns the first child which equals the given tag.
*/
+export function childByTag<K extends Uppercase<keyof HTMLElementTagNameMap>>(
+ element: Element,
+ tagName: K,
+): HTMLElementTagNameMap[Lowercase<K>] | null;
+export function childByTag(element: Element, tagName: string): Element | null;
export function childByTag(element: Element, tagName: string): Element | null {
return _getChildren(element, Type.TagName, tagName)[0] || null;
}
/**
* Examines child elements and returns all children which equal the given tag.
*/
+export function childrenByTag<K extends Uppercase<keyof HTMLElementTagNameMap>>(
+ element: Element,
+ tagName: K,
+): HTMLElementTagNameMap[Lowercase<K>][];
+export function childrenByTag(element: Element, tagName: string): Element[];
export function childrenByTag(element: Element, tagName: string): Element[] {
return _getChildren(element, Type.TagName, tagName);
}
return;
}
- const list = DomTraverse.childByTag(container, "UL") as HTMLUListElement;
+ const list = DomTraverse.childByTag(container, "UL");
if (list === null) {
throw "Expected an <ul> element as child of container '" + containerId + "'.";
}
availableWidth -= DomUtil.styleAsInt(styles, "margin-right");
const list = _itemLists.get(containerId)!;
- const items = DomTraverse.childrenByTag(list, "LI") as HTMLLIElement[];
+ const items = DomTraverse.childrenByTag(list, "LI");
let dropdown = _dropdowns.get(containerId);
let dropdownWidth = 0;
if (dropdown !== undefined) {
return false;
}
- const nav = DomTraverse.childByTag(this.container, "NAV") as HTMLElement;
+ const nav = DomTraverse.childByTag(this.container, "NAV");
if (nav === null) {
return false;
}
return false;
}
- DomTraverse.childrenByTag(this.container, "DIV").forEach((container: HTMLElement) => {
+ DomTraverse.childrenByTag(this.container, "DIV").forEach((container) => {
let name = container.dataset.name;
if (!name) {
name = DomUtil.identify(container);