Sha256: 07026408b071e7f6d9949f24ce81d1c56d73606e243c938cd18eb807388e36c7
Contents?: true
Size: 1.29 KB
Versions: 271
Compression:
Stored size: 1.29 KB
Contents
/* global axe, aria, dom, text */ /** * Gets the accessible ARIA label text of a given element * @see http://www.w3.org/WAI/PF/aria/roles#namecalculation * @method labelVirtual * @memberof axe.commons.aria * @instance * @param {Object} actualNode The virtualNode to test * @return {Mixed} String of visible text, or `null` if no label is found */ aria.labelVirtual = function({ actualNode }) { let ref, candidate; if (actualNode.getAttribute('aria-labelledby')) { // aria-labelledby ref = dom.idrefs(actualNode, 'aria-labelledby'); candidate = ref .map(function(thing) { const vNode = axe.utils.getNodeFromTree(thing); return vNode ? text.visibleVirtual(vNode, true) : ''; }) .join(' ') .trim(); if (candidate) { return candidate; } } // aria-label candidate = actualNode.getAttribute('aria-label'); if (candidate) { candidate = text.sanitize(candidate).trim(); if (candidate) { return candidate; } } return null; }; /** * Gets the aria label for a given node * @method label * @memberof axe.commons.aria * @instance * @param {HTMLElement} node The element to check * @return {Mixed} String of visible text, or `null` if no label is found */ aria.label = function(node) { node = axe.utils.getNodeFromTree(node); return aria.labelVirtual(node); };
Version data entries
271 entries across 271 versions & 1 rubygems