Skip to content
This repository was archived by the owner on Jul 23, 2024. It is now read-only.

Commit 121cb0e

Browse files
committed
Use waler.querySelectorAll() instead of tracing manually
1 parent 70e33f0 commit 121cb0e

1 file changed

Lines changed: 2 additions & 24 deletions

File tree

  • extension/experiments/inspectedNode

extension/experiments/inspectedNode/api.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,8 @@ this.inspectedNode = class extends ExtensionAPI {
5151
};
5252

5353
const _getSubtreeNodes = async (node) => {
54-
if (!node.hasChildren) {
55-
return [];
56-
}
57-
58-
const nodes = [];
59-
60-
// At first, get the children cache in nodeFront.
61-
let children = await node.treeChildren();
62-
63-
if (children.length === 0) {
64-
// Otherwise, get via the walker.
65-
await node.walkerFront.children(node);
66-
children = await node.treeChildren();
67-
}
68-
69-
// We see element type only
70-
children = children.filter(node => node.nodeType === ELEMENT_NODE);
71-
72-
for (const child of children) {
73-
nodes.push(child);
74-
nodes.push(...(await _getSubtreeNodes(child)));
75-
}
76-
77-
return nodes;
54+
const result = await node.walkerFront.querySelectorAll(node, "*");
55+
return await result.items();
7856
}
7957

8058
const _getAppliedStyle = async (inspector, node, option) => {

0 commit comments

Comments
 (0)