/** * Convert an HTML string to a DOM element. * * Parses an HTML string using DOMParser and returns the first child element * from the body of the resulting document. This is useful for creating DOM * elements from HTML strings in a safe and efficient way. * * @param html - A valid HTML string to be converted to a DOM element * @returns The first child element from the parsed HTML, or undefined if no elements exist * * @throws {TypeError} When html parameter is not a string * @throws {Error} When the HTML string is invalid or results in no elements * * @example * ```typescript * // Create a simple paragraph element * const paragraph = domify('

Hello, World!

'); * console.log(paragraph?.tagName); // 'P' * console.log(paragraph?.textContent); // 'Hello, World!' * * // Create a more complex element with attributes * const link = domify('Click me'); * console.log(link?.getAttribute('href')); // 'https://example.com' * console.log(link?.className); // 'btn' * * // Handle multiple elements (only first is returned) * const firstDiv = domify('
First
Second
'); * console.log(firstDiv?.textContent); // 'First' * ``` * * @example * ```typescript * // Type checking example * const element = domify(''); * if (element instanceof HTMLButtonElement) { * console.log(element.type); // 'submit' * } * ``` * * @public */ export declare function domify(html: string): Element | undefined;