Skip to content

onNodeInserted

Calls a listener when the element is inserted into the DOM. The mock observes nothing: it calls the listener once, immediately.

Import:

import 'obsidian-test-mocks/setup';

Signature:

function onNodeInserted(this: HTMLElement, listener: () => unknown, _once: boolean | undefined): () => void

Parameters:

Parameter Type Description
this HTMLElement
listener () => unknown The callback to call when the element is inserted.
_once boolean | undefined Whether the listener fires only once. Unused by the mock.

Returns: () => void — A function that removes the handler; a no-op in the mock.