Skip to content

Commit 1f20b70

Browse files
committed
refactored prune ax tree function to only push nodes with the role type "role"
1 parent d9edf47 commit 1f20b70

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/extension/background.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const pruneAxTree = (axTree) => {
2727
ignoredReasons,
2828
parentId,
2929
properties,
30+
role
3031
} = node;
3132

3233
if(!name){
@@ -40,22 +41,23 @@ const pruneAxTree = (axTree) => {
4041
if(!name.value){
4142
name.value = 'visible node with no name';
4243
}
43-
const axNode = {
44-
backendDOMNodeId: backendDOMNodeId,
45-
childIds: childIds,
46-
ignored: ignored,
47-
name: name,
48-
nodeId: nodeId,
49-
ignoredReasons: ignoredReasons,
50-
parentId: parentId,
51-
properties: properties,
52-
};
53-
54-
console.log('axNode: ', axNode);
5544

56-
axArr.push(axNode);
45+
if (role.type === 'role') {
46+
const axNode = {
47+
backendDOMNodeId: backendDOMNodeId,
48+
childIds: childIds,
49+
ignored: ignored,
50+
name: name,
51+
nodeId: nodeId,
52+
ignoredReasons: ignoredReasons,
53+
parentId: parentId,
54+
properties: properties,
55+
};
56+
57+
axArr.push(axNode);
58+
}
5759
}
58-
60+
console.log('axArr: ', axArr);
5961
return axArr;
6062
};
6163

@@ -476,6 +478,7 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
476478
await attachDebugger(tabId, '1.3');
477479
await sendDebuggerCommand(tabId, 'Accessibility.enable');
478480
const response = await sendDebuggerCommand(tabId, 'Accessibility.getFullAXTree');
481+
console.log('response: ', response);
479482
const addedAxSnap = addAxSnap(response.nodes);
480483
await detachDebugger(tabId);
481484
return addedAxSnap;

0 commit comments

Comments
 (0)