diff --git a/accessibility-checker-engine/src/v2/checker/accessibility/util/legacy.ts b/accessibility-checker-engine/src/v2/checker/accessibility/util/legacy.ts index 9523e5bc8..05ecdd60d 100644 --- a/accessibility-checker-engine/src/v2/checker/accessibility/util/legacy.ts +++ b/accessibility-checker-engine/src/v2/checker/accessibility/util/legacy.ts @@ -1369,6 +1369,21 @@ export class RPTUtil { return walkNode; } + /** + * return all the ancestor element names of the given element + * @param element + */ + public static getAncestorNames(element) { + if (!element) return null; + let ancestors = []; + let walkNode = DOMWalker.parentNode(element); + while (walkNode !== null) { + ancestors.push(walkNode.nodeName.toLowerCase()); + walkNode = DOMWalker.parentNode(walkNode); + } + return ancestors; + } + // return true if element1 and element2 are siblings public static isSibling(element1, element2) { if (element1 && element2) { diff --git a/accessibility-checker-engine/src/v4/rules/aria_banner_single.ts b/accessibility-checker-engine/src/v4/rules/aria_banner_single.ts index 9cc462829..dd611aae8 100644 --- a/accessibility-checker-engine/src/v4/rules/aria_banner_single.ts +++ b/accessibility-checker-engine/src/v4/rules/aria_banner_single.ts @@ -38,7 +38,7 @@ export let aria_banner_single: Rule = { } }, rulesets: [{ - "id": ["IBM_Accessibility", "WCAG_2_1", "WCAG_2_0"], + "id": ["IBM_Accessibility", "WCAG_2_1", "WCAG_2_0", "WCAG_2_2"], "num": ["2.4.1"], "level": eRulePolicy.VIOLATION, "toolkitLevel": eToolkitLevel.LEVEL_THREE diff --git a/accessibility-checker-engine/src/v4/rules/element_tabbable_unobscured.ts b/accessibility-checker-engine/src/v4/rules/element_tabbable_unobscured.ts index d4d8e8f5d..135489f98 100644 --- a/accessibility-checker-engine/src/v4/rules/element_tabbable_unobscured.ts +++ b/accessibility-checker-engine/src/v4/rules/element_tabbable_unobscured.ts @@ -60,11 +60,17 @@ export let element_tabbable_unobscured: Rule = { if (!bounds) return null; //ignore if offscreen - if (bounds['height'] === 0 || bounds['width'] === 0 || bounds['top'] < 0 || bounds['left'] < 0) + if (bounds['height'] === 0 || bounds['width'] === 0 ) return null; - let passed = true; - var elems = document.querySelectorAll('body *:not(' + nodeName +' *, ' + nodeName +')'); + const ancestors = RPTUtil.getAncestorNames(ruleContext); + let ignoreList = nodeName +' *, ' + nodeName +', script'; + if (ancestors) { + ancestors.forEach(ancestor=> { + ignoreList += ", " + ancestor; + }); + } + var elems = ruleContext.ownerDocument.querySelectorAll('body *:not(' + ignoreList +')'); console.log("select target=" + nodeName + ", elems="+elems.length); if (!elems || elems.length == 0) return; @@ -73,15 +79,17 @@ export let element_tabbable_unobscured: Rule = { elems.forEach(elem => { // Skip hidden if (VisUtil.isNodeVisible(elem)) { - const bnds = mapper.getBounds(elem); - if (bnds.top <= bounds.top && bnds.left <= bounds.left && bnds.top + bnds.height >= bounds.top + bounds.height - && bnds.top + bnds.height >= bounds.left + bounds.width) - violations.push(elem); + const bnds = mapper.getBounds(elem); console.log("target=" + nodeName + ", current=" + elem.nodeName + ", bounds=" + JSON.stringify(bounds) +", bnds=" + JSON.stringify(bnds)); + if (bnds.height !== 0 && bnds.width !== 0 + && bnds.top <= bounds.top && bnds.left <= bounds.left && bnds.top + bnds.height >= bounds.top + bounds.height + && bnds.left + bnds.height >= bounds.left + bounds.width) { + violations.push(elem); console.log("hit target=" + nodeName + ", current=" + elem.nodeName + ", bounds=" + JSON.stringify(bounds) +", bnds=" + JSON.stringify(bnds)); + } } }); if (violations.length > 0) - return RulePotential("potential_visible", []); + return RulePotential("potential_obscured", []); return RulePass("pass"); } diff --git a/accessibility-checker-engine/src/v4/rules/input_label_before.ts b/accessibility-checker-engine/src/v4/rules/input_label_before.ts index d9bba8d64..8baf9905e 100644 --- a/accessibility-checker-engine/src/v4/rules/input_label_before.ts +++ b/accessibility-checker-engine/src/v4/rules/input_label_before.ts @@ -41,7 +41,7 @@ export let input_label_before: Rule = { } }, rulesets: [{ - "id": ["IBM_Accessibility", "WCAG_2_1", "WCAG_2_0"], + "id": ["IBM_Accessibility", "WCAG_2_1", "WCAG_2_0", "WCAG_2_2"], "num": ["3.3.2"], "level": eRulePolicy.VIOLATION, "toolkitLevel": eToolkitLevel.LEVEL_ONE