queryStegaElementsLive
@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
- cb*-TQueryStegaElementsLiveCallback
The callback called with each detected stega element
- settings{}Partial<TQueryStegaElementsLiveSettings>
Optional settings
Return
- -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
- rootNodedocumentHTMLElement | Document
The root node to observe
- oncetrueBoolean
Only call the callback once per element
- when*-TWhenTrigger
Call the callback only when the trigger is fulfilled
- [disconnectedCallback=undefined] Called when a detected element is cleand from the DOM*-Function
null
- attributestrueBoolean | String[]
If true, check all attributes. If false, skip attributes. If string[], check only listed attributes.
- cleantrueBoolean
If true, strip the stega payload from the DOM after detection