File "child.ts"

Full path: /home/fsibplc/public_html/sommilito-bank2/splide-4.1.3/src/js/utils/dom/child/child.ts
File size: 500 B (500 B bytes)
MIME-type: text/x-java
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

import { children } from '../children/children';


/**
 * Returns a child element that matches the specified tag or class name.
 *
 * @param parent   - A parent element.
 * @param selector - A selector to filter children.
 *
 * @return A matched child element if available, or otherwise `undefined`.
 */
export function child<E extends HTMLElement>( parent: HTMLElement, selector?: string ): E | undefined {
  return selector ? children<E>( parent, selector )[ 0 ] : parent.firstElementChild as E;
}