Skip to content

Commit

Permalink
Issue 669 (#670)
Browse files Browse the repository at this point in the history
* Don't try to serialize copy Node references
* Update last archive
* Handle DOM implementations that don't have inheritance
  • Loading branch information
tombrunet authored Feb 2, 2022
1 parent 568726b commit 2b500c9
Show file tree
Hide file tree
Showing 6 changed files with 21,462 additions and 20,824 deletions.
4 changes: 2 additions & 2 deletions accessibility-checker-engine/src/v2/aria/ARIAMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class ARIAMapper extends CommonMapper {
[role: string]: number
}
}> = JSON.parse(JSON.stringify(this.hierarchyPath));
let hierarchyResults: IMapResult[] = JSON.parse(JSON.stringify(this.hierarchyResults));
let hierarchyResults: IMapResult[] = DOMUtil.objectCopyWithNodeRefs(this.hierarchyResults);
let attrValue = elem.getAttribute("aria-owns");
let ids = attrValue.trim().split(" ");
ids.forEach((id) => {
Expand Down Expand Up @@ -161,7 +161,7 @@ export class ARIAMapper extends CommonMapper {
hierarchyRole: JSON.parse(JSON.stringify(this.hierarchyRole)),
hierarchyChildrenHaveRole: JSON.parse(JSON.stringify(this.hierarchyChildrenHaveRole)),
hierarchyPath: JSON.parse(JSON.stringify(this.hierarchyPath)),
hierarchyResults: JSON.parse(JSON.stringify(this.hierarchyResults))
hierarchyResults: DOMUtil.objectCopyWithNodeRefs(this.hierarchyResults)
};

//rewrite parent hierarchy to the element with aria-owns
Expand Down
30 changes: 30 additions & 0 deletions accessibility-checker-engine/src/v2/dom/DOMUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,36 @@ export class DOMUtil {
while (nd != null && nd.nodeType !== Node.DOCUMENT_FRAGMENT_NODE)
nd = nd.parentNode;
return nd;
}

/**
* Copies objects, but retains Node attributes as references
* @param rhs
*/
static objectCopyWithNodeRefs(rhs: any) {
if (!rhs) return rhs;
if (typeof rhs !== "object") {
if (typeof rhs === "function") {
return rhs;
} else {
return JSON.parse(JSON.stringify(rhs));
}
} else if (rhs instanceof Node || !!rhs.nodeType) {
return rhs;
} else {
let retVal;
if (rhs.constructor.name === "Array") {
retVal = [];
for (const item of rhs) {
retVal.push(this.objectCopyWithNodeRefs(item));
}
} else {
retVal = {};
for (const key in rhs) {
retVal[key] = this.objectCopyWithNodeRefs(rhs[key]);
}
}
return retVal;
}
}
}
37 changes: 34 additions & 3 deletions rule-server/src/static/archives/2022.02.01/js/ace-debug.js

Large diffs are not rendered by default.

Loading

0 comments on commit 2b500c9

Please sign in to comment.