in src/scanner/custom-rules/unique-landmark.ts [90:127]
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<any> = [];
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;
}
}
}
}
return true;
}