Skip to content

createElAsync<K>

Creates an element asynchronously.

Not refactored to parameter-object pattern, to keep the parity with Obsidian’s createEl (or createSvg, correspondingly).

Import:

import { createElAsync } from '@mnaoumov/typescript-lib/html-element';

Signature:

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

Parameters:

Parameter Type Description
tag K The tag name of the element to create.
o string | CreateHtmlElementInfo | undefined The element information.
callback ((element: HTMLElementTagNameMap[K]) => Promisable<void>) | undefined The callback to call when the element is created.

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


Links to this page: