Skip to content

Commit 968333c

Browse files
shunguoydependabot[bot]tombrunetnam-singh
authored
fix(engine): fix circular structure caused by aria-owns V4 (#2166)
* Bump path-to-regexp and express in /rule-server (#2128) Bumps [path-to-regexp](https://github.com/pillarjs/path-to-regexp) to 0.1.12 and updates ancestor dependency [express](https://github.com/expressjs/express). These dependencies need to be updated together. Updates `path-to-regexp` from 0.1.10 to 0.1.12 - [Release notes](https://github.com/pillarjs/path-to-regexp/releases) - [Changelog](https://github.com/pillarjs/path-to-regexp/blob/master/History.md) - [Commits](pillarjs/path-to-regexp@v0.1.10...v0.1.12) Updates `express` from 4.21.0 to 4.21.2 - [Release notes](https://github.com/expressjs/express/releases) - [Changelog](https://github.com/expressjs/express/blob/4.21.2/History.md) - [Commits](expressjs/express@4.21.0...4.21.2) --- updated-dependencies: - dependency-name: path-to-regexp dependency-type: indirect - dependency-name: express dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tom Brunet <thbrunet@us.ibm.com> * fix dark mode react portal pop-up (#2138) * fix(extension):Fix reset filter link #1877 (#2136) * reset filter fix * css fix --------- Co-authored-by: Tom Brunet <thbrunet@us.ibm.com> * fix(extension): Don't show full data:text/html content on generated HTML report page (#2140) * truncating url * remove unused import * Adjust tooltip location --------- Co-authored-by: Tom Brunet <thbrunet@us.ibm.com> * chore(extension): carbon package update and use new carbon combobutton #1842 (#2137) * carbon package update and use new carbon combobutton * alignment fix --------- Co-authored-by: Tom Brunet <thbrunet@us.ibm.com> * fix circular structure caused by aria-owns --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tom Brunet <thbrunet@us.ibm.com> Co-authored-by: Namrata Singh <nam.singh@ibm.com>
1 parent a5559ab commit 968333c

File tree

3 files changed

+76
-5
lines changed

3 files changed

+76
-5
lines changed

accessibility-checker-engine/karma.conf.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@
4747
//{ pattern: 'test/v2/checker/accessibility/rules/label_name_visible_ruleunit/label_offscreen.html', watched: true },
4848
//{ pattern: 'test/v2/checker/accessibility/rules/aria_role_valid_ruleunit/td_attribute_invalid_copy.html', watched: true },
4949
//{ pattern: 'test/v2/checker/accessibility/rules/text_block_heading_ruleunit/Headings-noneUsedEmphasizedText.html', watched: true },
50-
{ pattern: 'test/v2/checker/accessibility/rules/aria_landmark_name_unique_ruleunit/*.html', watched: true },
50+
//{ pattern: 'test/v2/checker/accessibility/rules/aria_landmark_name_unique_ruleunit/*.html', watched: true },
5151
// { pattern: 'test/v2/checker/accessibility/rules/aria_parent_required_ruleunit/webComponentPass2.html', watched: true },
5252

5353

54-
// { pattern: 'test/**/*_ruleunit/*.html', watched: true },
55-
// { pattern: 'test/**/*_ruleunit/*.htm', watched: true },
54+
{ pattern: 'test/**/*_ruleunit/*.html', watched: true },
55+
{ pattern: 'test/**/*_ruleunit/*.htm', watched: true },
5656
// all files ending in "_test"
5757
// { pattern: 'test/*_test.js', watched: true },
5858
{ pattern: 'test/**/*_test.js', watched: true }

accessibility-checker-engine/src/v2/aria/ARIAMapper.ts

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,45 @@ export class ARIAMapper extends CommonMapper {
9595
for (let iId=0; iId < ownIds.length; ++iId) {
9696
const owned = doc.getElementById(ownIds[iId]);
9797
//ignore if the aria-owns point to the element itself
98-
if (owned && !DOMUtil.sameNode(owner, owned)) {
99-
CacheUtil.setCache(owned, "aria-owned", owner);
98+
//if (owned && !DOMUtil.sameNode(owner, owned)) {
99+
// CacheUtil.setCache(owned, "aria-owned", owner);
100+
//}
101+
/**
102+
* circular hierarchy check:
103+
* (1) the owned element is neither the same element with the owner nor any ascendant of the owner
104+
* (2) any child with aria-owns cannot point to the owner or any ascendant of the owner
105+
*/
106+
if (owned && !DOMUtil.sameNode(owner, owned)) {
107+
// check if the owned with aria-owns that points to another element
108+
let ownedNodes = [];
109+
const sub_owners = owned.querySelectorAll("[aria-owns]");
110+
for (let i = 0; i < sub_owners.length; ++i) {
111+
const sub_owner = sub_owners[i];
112+
const sub_ownIds = sub_owner.getAttribute("aria-owns").split(/ +/g);
113+
for (let j=0; j < sub_ownIds.length; ++j) {
114+
const ownedNode = doc.getElementById(sub_ownIds[j]);
115+
if (ownedNode)
116+
ownedNodes.push(ownedNode);
117+
}
118+
}
119+
if (ownedNodes.length === 0) {
120+
CacheUtil.setCache(owned, "aria-owned", owner);
121+
continue;
122+
}
123+
// check if any aria-owns points to the element itself or any of it's parent
124+
let parent : Element = owner;
125+
let circular = false;
126+
while (parent !== null) {
127+
const found = ownedNodes.some(item => DOMUtil.sameNode(parent, item));
128+
if (!found)
129+
parent = DOMWalker.parentElement(parent);
130+
else {
131+
circular = true;
132+
break;
133+
}
134+
}
135+
if (!circular)
136+
CacheUtil.setCache(owned, "aria-owned", owner);
100137
}
101138
}
102139
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html lang="en-US">
3+
4+
<head>
5+
<title>Sandbox</title>
6+
<meta charset="UTF-8" />
7+
</head>
8+
9+
<body>
10+
<div class="mm-panels">
11+
<div id="mm-1" class="mm-panel mm-panel_opened">
12+
<ul class="mm-listview">
13+
<li class="mm-listitem"><a href="#mm-2" aria-owns="mm-2">Open submenu</a>
14+
<li class="mm-listitem"><a href="#mm-3" aria-owns="mm-3">Open Another submenu</a>
15+
</li>
16+
</ul>
17+
</div>
18+
<div id="mm-3">
19+
<div class="mm-navbar"><a href="#mm-1" aria-owns="mm-1">Close submenu</a>
20+
</div>
21+
</div>
22+
</div>
23+
</body>
24+
<script>
25+
UnitTest = {
26+
ruleIds: ["aria_descendant_valid"],
27+
results: [
28+
29+
]
30+
}
31+
</script>
32+
</body>
33+
34+
</html>

0 commit comments

Comments
 (0)