Current Path : /var/www/www-root/data/www/info.monolith-realty.ru/bitrix/js/landing/menu/menu/src/ |
Current File : /var/www/www-root/data/www/info.monolith-realty.ru/bitrix/js/landing/menu/menu/src/build-tree.js |
export default function buildTree(root: HTMLElement, selector, parent = null, depth = 0) { return [...root.querySelectorAll(selector)] .filter((element) => { return element.parentElement.closest(selector) === parent; }) .map((element) => { const newDepth = depth + 1; return { layout: element, children: buildTree(element, selector, element, newDepth), depth, }; }); }