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.

57 lines 2.37 kB
var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spread = (this && this.__spread) || function () { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; }; import { Exception } from "@aurigma/design-atoms-model/Exception"; // TODO: to research selector alternative export function getChildElementsRecursive(rootElement) { var targetElementChildren = []; var getChildElements = function (element) { return Array.from(element.childNodes).filter(function (e) { return e.nodeType === Node.ELEMENT_NODE; }); }; var childrenStack = getChildElements(rootElement); var index = 0; while (childrenStack.length !== 0) { var element = childrenStack.shift(); targetElementChildren.push(element); childrenStack.push.apply(childrenStack, __spread(getChildElements(element))); index++; if (index > 100000) throw new Exception("Utils.getChildElementsRecursive: too many children!"); } return targetElementChildren; } export function addClassToElement(cssClass, element) { var _a; if (cssClass != null && cssClass !== "") { (_a = element.classList).add.apply(_a, __spread(cssClass.split(" "))); } } var 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