UNPKG

@aurigma/design-atoms

Version:

Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.

36 lines 1.61 kB
import { Exception } from "@aurigma/design-atoms-model/Exception"; // TODO: to research selector alternative export function getChildElementsRecursive(rootElement) { const targetElementChildren = []; const getChildElements = (element) => { return Array.from(element.childNodes).filter(e => e.nodeType === Node.ELEMENT_NODE); }; const childrenStack = getChildElements(rootElement); let index = 0; while (childrenStack.length !== 0) { const element = childrenStack.shift(); targetElementChildren.push(element); childrenStack.push(...getChildElements(element)); index++; if (index > 100000) throw new Exception("Utils.getChildElementsRecursive: too many children!"); } return targetElementChildren; } export function addClassToElement(cssClass, element) { if (cssClass != null && cssClass !== "") { element.classList.add(...cssClass.split(" ")); } } const stopPropagationFunc = function (e) { e.stopPropagation(); }; export function addPointerEventsStopPropagation(element) { element.addEventListener("mousedown", stopPropagationFunc); element.addEventListener("dblclick", stopPropagationFunc); element.addEventListener("touchstart", stopPropagationFunc); } export function removePointerEventsStopPropagation(element) { element.removeEventListener("mousedown", stopPropagationFunc); element.removeEventListener("dblclick", stopPropagationFunc); element.removeEventListener("touchstart", stopPropagationFunc); } //# sourceMappingURL=Dom.js.map