Skip to content

appendTextOrFragmentClone

Appends a string as text, or a fresh deep clone of a DocumentFragment, to the given element.

Appending a fragment moves its children out of it, so a fragment rendered more than once — a notice and a settings banner, or a banner rendered again on every refresh — would be empty from the second render on. Cloning leaves the caller’s fragment intact for the next render.

Import:

import { appendTextOrFragmentClone } from '@mnaoumov/obsidian-lib/html-element';

Signature:

function appendTextOrFragmentClone(element: HTMLElement | DocumentFragment, content: string | DocumentFragment): void

Parameters:

Parameter Type Description
element HTMLElement | DocumentFragment The DocumentFragment or HTMLElement to append to.
content string | DocumentFragment The text, or the fragment to append a clone of.

Returns: void