queryStegaElementsLive

Type:Function
Status:stable
Since:1.0.0
Platform:js
@blackbyte.sugar.js.dom.query

Monitor the specified rootNode element and all its descendants for stega encoded metadata, either in attributes or text content. When detected, calls the provided callback with the result. Uses a MutationObserver to react to DOM changes in real time.

Params

  1. cb*-TQueryStegaElementsLiveCallback

    The callback called with each detected stega element

  2. settings{}Partial<TQueryStegaElementsLiveSettings>

    Optional settings

Return

  1. -TQueryStegaElementsLiveApi

    API object with a cancel() method

Example

import { queryStegaElementsLive } from '@blackbyte/sugar/dom';
const query = queryStegaElementsLive(element => {
    console.log(element.$elm, element.decode());
});
// stop observing when needed
query.cancel();

Settings

  1. rootNodedocumentHTMLElement | Document

    The root node to observe

  2. oncetrueBoolean

    Only call the callback once per element

  3. when*-TWhenTrigger

    Call the callback only when the trigger is fulfilled

  4. [disconnectedCallback=undefined] Called when a detected element is cleand from the DOM*-Function

    null

  5. attributestrueBoolean | String[]

    If true, check all attributes. If false, skip attributes. If string[], check only listed attributes.

  6. cleantrueBoolean

    If true, strip the stega payload from the DOM after detection