Skip to content

Commit 25b5df1

Browse files
authored
Merge branch 'main' into zyzyzyryxy/bump_devtools_frontend
2 parents 3e5bfbd + 5aa6437 commit 25b5df1

3 files changed

Lines changed: 21 additions & 12 deletions

File tree

src/TextSnapshot.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,12 @@ export class TextSnapshot {
231231
};
232232

233233
const findDescendantNodes = async (
234-
backendNodeId: number,
234+
backendNodeId?: number,
235235
): Promise<Set<number>> => {
236236
const descendantIds = new Set<number>();
237+
if (!backendNodeId) {
238+
return descendantIds;
239+
}
237240
try {
238241
// @ts-expect-error internal API
239242
const client = page.pptrPage._client();
@@ -297,20 +300,26 @@ export class TextSnapshot {
297300
if (extraHandles.length) {
298301
page.extraHandles = extraHandles;
299302
}
303+
const reorgInfo: Array<{
304+
extraNode: TextSnapshotNode;
305+
attachTarget: TextSnapshotNode;
306+
descendantIds: Set<number>;
307+
}> = [];
308+
300309
for (const handle of page.extraHandles) {
301310
const extraNode = await createExtraNode(handle);
302311
if (!extraNode) {
303312
continue;
304313
}
305314
idToNode.set(extraNode.id, extraNode);
306315
const attachTarget = (await findAncestorNode(handle)) || rootNodeWithId;
307-
if (extraNode.backendNodeId !== undefined) {
308-
const descendantIds = await findDescendantNodes(
309-
extraNode.backendNodeId,
310-
);
311-
const index = moveChildNodes(attachTarget, extraNode, descendantIds);
312-
attachTarget.children.splice(index, 0, extraNode);
313-
}
316+
const descendantIds = await findDescendantNodes(extraNode.backendNodeId);
317+
reorgInfo.push({extraNode, attachTarget, descendantIds});
318+
}
319+
320+
for (const {extraNode, attachTarget, descendantIds} of reorgInfo) {
321+
const index = moveChildNodes(attachTarget, extraNode, descendantIds);
322+
attachTarget.children.splice(index, 0, extraNode);
314323
}
315324
}
316325
}

src/formatters/SnapshotFormatter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class SnapshotFormatter {
2020

2121
// Top-level content of the snapshot.
2222
if (
23-
this.#snapshot.verbose &&
23+
!this.#snapshot.verbose &&
2424
this.#snapshot.hasSelectedElement &&
2525
!this.#snapshot.selectedElementUid
2626
) {

tests/formatters/snapshotFormatter.test.js.snapshot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
exports[`snapshotFormatter > does not include a note if the snapshot is already verbose 1`] = `
2-
Note: there is a selected element in the DevTools Elements panel but it is not included into the current a11y tree snapshot.
3-
Get a verbose snapshot to include all elements if you are interested in the selected element.
4-
52
uid=1_1 checkbox "checkbox" checked
63
uid=1_2 statictext "text"
74

@@ -14,6 +11,9 @@ uid=1_1 checkbox "checkbox" checked [selected in the DevTools Elements panel]
1411
`;
1512

1613
exports[`snapshotFormatter > formats with DevTools data not included into a snapshot 1`] = `
14+
Note: there is a selected element in the DevTools Elements panel but it is not included into the current a11y tree snapshot.
15+
Get a verbose snapshot to include all elements if you are interested in the selected element.
16+
1717
uid=1_1 checkbox "checkbox" checked
1818
uid=1_2 statictext "text"
1919

0 commit comments

Comments
 (0)