UNPKG

@scania/tegel

Version:
16 lines (15 loc) 549 B
/** * Loop through the children and add the 'listitem' role if needed. * @param {Node} targetNode The node being updated. * */ const updateListChildrenRoles = (targetNode) => { targetNode.childNodes.forEach((node) => { if (node.nodeType === Node.ELEMENT_NODE) { const element = node; if (element.tagName.toLowerCase() !== 'li' && element.getAttribute('role') !== 'listitem') { element.setAttribute('role', 'listitem'); } } }); }; export default updateListChildrenRoles;