bc-node-sdk
Version:
BetterCommerce's NodeJS SDK encapsulates the base framework for all the Next.js applications.
34 lines (33 loc) • 1.65 kB
TypeScript
/**
* Class {@link DOMUtil} encapsulates utility functions to manipulate the DOM.
*/
export default abstract class DOMUtil {
/**
* Observes dom change by calling relevant callback to notify.
* @param selector
* @param domAddedCallback
* @param domRemovedCallback
*/
static domObserver(selector: string, domAddedCallback: any, domRemovedCallback: any): void;
/**
* Creates a MutationObserver that calls the provided callbacks when the
* observed element is added or removed from the DOM.
*
* @param domAddedCallback - Callback to call when the element is added to the DOM.
* The callback will receive an array of added nodes as an argument.
* @param domRemovedCallback - Callback to call when the element is removed from the DOM.
* The callback will receive an array of removed nodes as an argument.
*/
static domObserverEvent(domAddedCallback: any, domRemovedCallback: any): MutationObserver;
/**
* Sanitizes the given HTML content by parsing it and extracting the inner HTML from the document's body.
*
* This method attempts to parse the provided HTML string using the DOMParser. If the parsing is successful,
* it returns the inner HTML of the parsed document's body. In case of an error during parsing, the error is
* logged and a default empty string is returned.
*
* @param html - The HTML string to be sanitized and parsed.
* @returns The sanitized HTML content as a string, or a default empty string if an error occurs.
*/
static sanitizeHtmlContent(html: any): string;
}