Skip to content

createElAsync<K>

Creates an element asynchronously.

Not refactored to parameter-object pattern, to keep the parity with obsidian#createEl (or createSvg, correspondingly).

Import:

import { createElAsync } from 'obsidian-dev-utils/html-element';

Signature:

function createElAsync(tag: K, o: string | DomElementInfo | undefined, callback: ((el: HTMLElementTagNameMap[K]) => Promisable<void>) | undefined): Promise<HTMLElementTagNameMap[K]>

Parameters:

ParameterTypeDescription
tagKThe tag name of the element to create.
ostring | DomElementInfo | undefinedThe element information.
callback((el: HTMLElementTagNameMap[K]) => Promisable<void>) | undefinedThe callback to call when the element is created.

Returns: Promise<HTMLElementTagNameMap[K]> — A Promise that resolves to the element.