Skip to content

Commit

Permalink
Path fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
tombrunet committed Nov 5, 2024
1 parent 2918ef8 commit 516ab45
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 11 deletions.
5 changes: 3 additions & 2 deletions accessibility-checker-engine/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion accessibility-checker-engine/src/v2/common/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
41 changes: 36 additions & 5 deletions accessibility-checker-engine/src/v2/dom/DOMWalker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -107,31 +114,38 @@ 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;
} else if (this.node.nodeType === 1
&& 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;
Expand All @@ -141,22 +155,39 @@ 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;
}
}
} while (
(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<this.indent; ++idx) {
s += " ";
}
return s;
}
if (this.bEndTag) this.indent -= 2;
this.DEBUG && console.log(indent()+`<${this.bEndTag?"/":""}${this.node.nodeName}> (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;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Issue 741</title
<title>Issue 741</title>
<meta charset="UTF-8" />
<template id="my-list" >
<template id="my-list">
<div>
<slot id="slot1" name="heading"></slot>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<main id="mymain">
<h1>Test page</h1>
<my-list id="mylist">
<div role="heading" aria-level="4" slot="heading" id="'mydev">Something</div>
<div role="heading" aria-level="4" slot="heading" id="mydev">Something</div>
<my-list-item role="listitem" id="mylistItem">Sample item</my-list-item>
</my-list>
</main>
Expand Down

0 comments on commit 516ab45

Please sign in to comment.