Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function evaluate(node: any, options: any): boolean {
if (isLandmark(node) === false) {
return false;
}
const role = getObservedRoleForElement(node);
let label = axe.commons.aria.label(node);
let candidates: Array = [];
const selectors = getRoleSelectors(role);
const selectorsLength = selectors.length;
label = label ? label.toLowerCase() : null;
// tslint:disable-next-line:no-invalid-this
this.data({ role: role, label: label });
for (let selectorPos = 0; selectorPos < selectorsLength; selectorPos++) {
candidates = candidates.concat(
axe.utils.toArray(document.querySelectorAll(selectors[selectorPos])),
);
}
const candidatesLength = candidates.length;
if (candidatesLength > 1) {
for (let candidatePos = 0; candidatePos < candidatesLength; candidatePos++) {
const candidate = candidates[candidatePos];
if (
candidate !== node &&
isLandmark(candidate) &&
axe.commons.dom.isVisible(candidate, true)
) {
let candidateLabel = axe.commons.aria.label(candidate);
candidateLabel = candidateLabel ? candidateLabel.toLowerCase() : null;
if (label === candidateLabel) {
return false;
}
export function isImage(node: HTMLElement, virtualNode: HTMLElement): boolean {
const selector: string = 'img, [role=img], svg';
if (axe.utils.matchesSelector(node, selector)) {
return true;
}
if (node.tagName.toLowerCase() === 'i' && node.innerHTML === '') {
return true;
}
if (AxeUtils.hasBackgoundImage(node)) {
return true;
}
return false;
}