From 516ab458b2b0d51df736789f498d8b7fc192e324 Mon Sep 17 00:00:00 2001 From: Tom Brunet Date: Tue, 5 Nov 2024 13:03:27 -0600 Subject: [PATCH] Path fix? --- accessibility-checker-engine/karma.conf.js | 5 ++- .../src/v2/common/Engine.ts | 2 +- .../src/v2/dom/DOMWalker.ts | 41 ++++++++++++++++--- .../webComponentPass.html | 4 +- .../webComponentPass2.html | 2 +- 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/accessibility-checker-engine/karma.conf.js b/accessibility-checker-engine/karma.conf.js index 62a4bb4f2..9ba11327a 100644 --- a/accessibility-checker-engine/karma.conf.js +++ b/accessibility-checker-engine/karma.conf.js @@ -48,10 +48,11 @@ //{ pattern: 'test/v2/checker/accessibility/rules/aria_role_valid_ruleunit/td_attribute_invalid_copy.html', watched: true }, //{ pattern: 'test/v2/checker/accessibility/rules/text_block_heading_ruleunit/Headings-noneUsedEmphasizedText.html', watched: true }, { pattern: 'test/v2/checker/accessibility/rules/aria_parent_required_ruleunit/webComponentPass.html', watched: true }, + { pattern: 'test/v2/checker/accessibility/rules/aria_parent_required_ruleunit/webComponentPass2.html', watched: true }, - //{ pattern: 'test/**/*_ruleunit/*.html', watched: true }, - //{ pattern: 'test/**/*_ruleunit/*.htm', watched: true }, + { pattern: 'test/**/*_ruleunit/*.html', watched: true }, + { pattern: 'test/**/*_ruleunit/*.htm', watched: true }, // all files ending in "_test" // { pattern: 'test/*_test.js', watched: true }, { pattern: 'test/**/*_test.js', watched: true } diff --git a/accessibility-checker-engine/src/v2/common/Engine.ts b/accessibility-checker-engine/src/v2/common/Engine.ts index 03e25f7ec..ba4da390a 100644 --- a/accessibility-checker-engine/src/v2/common/Engine.ts +++ b/accessibility-checker-engine/src/v2/common/Engine.ts @@ -163,7 +163,7 @@ export class Engine implements IEngine { } root.ownerDocument && ((root.ownerDocument as any).PT_CHECK_HIDDEN_CONTENT = false); CacheUtil.clearCaches(root); - const walker = new DOMWalker(root, false, root, true); + const walker = new DOMWalker(root, false, root, true, false); const retVal : Report = { results: [], numExecuted: 0, diff --git a/accessibility-checker-engine/src/v2/dom/DOMWalker.ts b/accessibility-checker-engine/src/v2/dom/DOMWalker.ts index 92222e070..5fcbac6bf 100644 --- a/accessibility-checker-engine/src/v2/dom/DOMWalker.ts +++ b/accessibility-checker-engine/src/v2/dom/DOMWalker.ts @@ -25,8 +25,10 @@ export class DOMWalker { node : Node; bEndTag: boolean; considerHidden: boolean; + DEBUG: boolean; - constructor(element : Node, bEnd? : boolean, root? : Node, considerHidden? : boolean) { + constructor(element : Node, bEnd? : boolean, root? : Node, considerHidden? : boolean, DEBUG?: boolean) { + this.DEBUG = !!DEBUG; this.root = root || ((element && element.ownerDocument) ? element.ownerDocument.documentElement: element); if (this.root.nodeType === 9) { this.root = (this.root as Document).documentElement @@ -82,7 +84,11 @@ export class DOMWalker { } } + DEBUGIDX = 0; + indent = 0; nextNode() : boolean { + let DBG = false;//this.DEBUGIDX >= 7 && this.DEBUGIDX <= 10; + let startName = this.node.nodeName; if (!this.node) { this.bEndTag = false; return false; @@ -99,6 +105,7 @@ export class DOMWalker { && iframeNode.contentDocument && iframeNode.contentDocument.documentElement) { + DBG && console.log("!!!0a"); let ownerElement = this.node; this.node = iframeNode.contentDocument.documentElement; (this.node as any).ownerElement = ownerElement; @@ -107,6 +114,7 @@ export class DOMWalker { && elementNode.shadowRoot && elementNode.shadowRoot.firstChild) { + DBG && console.log("!!!0b"); let ownerElement = this.node; this.node = elementNode.shadowRoot; (this.node as any).ownerElement = ownerElement; @@ -114,24 +122,30 @@ export class DOMWalker { && elementNode.nodeName.toLowerCase() === "slot" && slotElement.assignedNodes().length > 0) { + DBG && console.log("!!!0c"); let slotOwner = this.node; this.node = slotElement.assignedNodes()[0]; (this.node as any).slotOwner = slotOwner; (this.node as any).slotIndex = 0; - } else if ((this.node.nodeType === 1 /* Node.ELEMENT_NODE */ || this.node.nodeType === 11 /* Node.DOCUMENT_FRAGMENT_NODE */) && this.node.firstChild) { + } else if ((this.node.nodeType === 1 /* Node.ELEMENT_NODE */ || this.node.nodeType === 11 /* Node.DOCUMENT_FRAGMENT_NODE */) && this.node.firstChild && !(this.node.firstChild as any).slotOwner) { + DBG && console.log("!!!0d"); this.node = this.node.firstChild; } else { + DBG && console.log("!!!0e"); this.bEndTag = true; } } else { + DBG && console.log("!!!1"); if (this.atRoot()) { + DBG && console.log("!!!1a"); return false; } else if ((this.node as any).slotOwner) { + DBG && console.log("!!!1b"); let slotOwner = (this.node as any).slotOwner; let nextSlotIndex = (this.node as any).slotIndex+1; - delete (this.node as any).slotOwner; - delete (this.node as any).slotIndex; - if (nextSlotIndex < slotOwner.assignedNodes().length) { + // delete (this.node as any).slotOwner; + // delete (this.node as any).slotIndex; + if (nextSlotIndex < slotOwner.assignedNodes().length) { this.node = slotOwner.assignedNodes()[nextSlotIndex]; (this.node as any).slotOwner = slotOwner; (this.node as any).slotIndex = nextSlotIndex; @@ -141,15 +155,19 @@ export class DOMWalker { this.bEndTag = true; } } else if ((this.node as any).ownerElement) { + DBG && console.log("!!!1c"); this.node = (this.node as any).ownerElement; this.bEndTag = true; } else if (this.node.nextSibling) { + DBG && console.log("!!!1d"); this.node = this.node.nextSibling; this.bEndTag = false; } else if (this.node.parentNode) { + DBG && console.log("!!!1e"); this.node = this.node.parentNode; this.bEndTag = true; } else { + DBG && console.log("!!!f"); return false; } } @@ -157,6 +175,19 @@ export class DOMWalker { (this.node.nodeType !== 1 && this.node.nodeType !== 11 && this.node.nodeType !== 3 ) || (this.node.nodeType === 1 && (this.node as Element).getAttribute("aChecker") === "ACE") ); + const indent = () => { + let s = ""; + for (let idx=0; idx (from ${startName}) ${this.DEBUGIDX++}`); + this.DEBUG && (this.node as any).slotOwner && console.log(indent()+`slotOwner: ${(this.node as any).slotOwner.nodeName}`); + this.DEBUG && (this.node as any).slotIndex && console.log(indent()+`slotIndex: ${(this.node as any).slotIndex}`); + this.DEBUG && (this.node as any).ownerElement && console.log(indent()+`ownerElement: ${(this.node as any).ownerElement.nodeName}`); + if (!this.bEndTag) this.indent += 2; return true; } diff --git a/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_parent_required_ruleunit/webComponentPass.html b/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_parent_required_ruleunit/webComponentPass.html index c757895d6..a16b9d51c 100644 --- a/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_parent_required_ruleunit/webComponentPass.html +++ b/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_parent_required_ruleunit/webComponentPass.html @@ -1,9 +1,9 @@ - Issue 741Issue 741 -