UNPKG

@blinkk/selective-edit

Version:
33 lines 1.07 kB
"use strict"; /** * DOM helper functions. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.findParentDraggable = exports.findParentByClassname = void 0; /** * Search the parent nodes of the element to find an parent * that has the given class. * * @param element DOM element to start search from. * @param classname CSS class to search for. */ const findParentByClassname = (element, classname) => { while (element && !element.classList.contains(classname)) { element = element.parentElement; } return element; }; exports.findParentByClassname = findParentByClassname; const findParentDraggable = (target) => { // Use the event target to traverse until the draggable element is found. let isDraggable = false; while (target && !isDraggable) { isDraggable = target.getAttribute('draggable') === 'true'; if (!isDraggable) { target = target.parentElement; } } return target; }; exports.findParentDraggable = findParentDraggable; //# sourceMappingURL=dom.js.map