Skip to content

Commit

Permalink
add debug for testing #1974
Browse files Browse the repository at this point in the history
  • Loading branch information
shunguoy committed Sep 12, 2024
1 parent 18db1dc commit 4e27b7b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions accessibility-checker-engine/src/v2/dom/DOMWalker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@ export class DOMWalker {
} else {
p = null;
}
}
}
return p;
}

static parentElement(node: Node) : Element | null {
let elem : Element = node as Element;
do { if (elem.nodeName == 'MY-LIST-ITEM') console.log("walker node=" + elem.nodeName +", role=" +elem.getAttribute("role") +", parent=" + DOMWalker.parentNode(elem).nodeName +", parent nodetype=" + DOMWalker.parentNode(elem).nodeType +", id=" + (DOMWalker.parentNode(elem) as Element).getAttribute("id") +", role=" + (DOMWalker.parentNode(elem) as Element).getAttribute("role"));
do {
elem = DOMWalker.parentNode(elem) as Element;
} while (elem && elem.nodeType !== 1);
if (node.nodeName == 'MY-LIST-ITEM') console.log("walker node=" + node.nodeName +", role=" + (node as Element).getAttribute("role") +", parent=" + elem.nodeName +", parent nodetype=" + elem.nodeType +", id=" + elem.getAttribute("id") +", role=" + elem.getAttribute("role"));
return elem;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export const aria_parent_required: Rule = {
act: "ff89c9",
run: (context: RuleContext, options?: {}, contextHierarchies?: RuleContextHierarchy): RuleResult | RuleResult[] => {
const ruleContext = context["dom"].node as HTMLElement;

//console.log("rule node="+ruleContext.nodeName + ", id="+ruleContext.getAttribute("id") +", roles=" + ruleContext.getAttribute("role"));

//skip the check if the element is hidden or disabled
if (VisUtil.isNodeHiddenFromAT(ruleContext) || CommonUtil.isNodeDisabled(ruleContext))
return;
Expand Down Expand Up @@ -81,7 +82,7 @@ export const aria_parent_required: Rule = {
count++;
parentRole = ancestorRoles[ancestorRoles.length - count];

}console.log("rule node="+ruleContext.nodeName + ", id="+ruleContext.getAttribute("id") +", roles=" + roles +", parentRole=" + parentRole +",ancestorRoles="+ancestorRoles);
} console.log("rule node="+ruleContext.nodeName + ", id="+ruleContext.getAttribute("id") +", roles=" + roles +", parentRole=" + parentRole +",ancestorRoles="+ancestorRoles);
for (let j = 0, length = roles.length; j < length; ++j) {
if (designPatterns[roles[j]] && designPatterns[roles[j]].container != null) {
testedContainer++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const text_block_heading: Rule = {
type: "integer"
}
}

let bodyFont = 0;
let body = ruleContext.ownerDocument.getElementsByTagName("body");
if (body != null) {
Expand All @@ -84,11 +84,11 @@ export const text_block_heading: Rule = {
nw.node !== DOMWalker.parentNode(ruleContext) &&
!["br", "div", "p"].includes(nw.node.nodeName.toLowerCase())) // Don't report twice
{
if (CommonUtil.shouldNodeBeSkippedHidden(nw.node))
if (nw.node === ruleContext || CommonUtil.shouldNodeBeSkippedHidden(nw.node))
continue;

let nwName = nw.node.nodeName.toLowerCase();
if (nw.node.nodeType === 3) {
if (nw.node.nodeType === 3) {
// for text child
if (nw.node.nodeValue.trim().length > 0 && nw.node.parentElement) {
// check it's style if the target element contains text, e.g., <p> fake heading</p>
Expand Down

0 comments on commit 4e27b7b

Please sign in to comment.