docs: fixing example code in accessibility API docs (#12664)

Co-authored-by: Andrey Lushnikov <aslushnikov@gmail.com>
This commit is contained in:
Andrew Hayward 2022-03-23 10:50:35 +00:00 committed by GitHub
parent 04e9d2ec08
commit ab39cfcb18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View file

@ -91,7 +91,8 @@ function findFocusedNode(node) {
return node;
for (const child of node.children || []) {
const foundNode = findFocusedNode(child);
return foundNode;
if (foundNode)
return foundNode;
}
return null;
}
@ -113,7 +114,8 @@ def find_focused_node(node):
return node
for child in (node.get("children") or []):
found_node = find_focused_node(child)
return found_node
if (found_node)
return found_node
return None
snapshot = await page.accessibility.snapshot()
@ -128,7 +130,8 @@ def find_focused_node(node):
return node
for child in (node.get("children") or []):
found_node = find_focused_node(child)
return found_node
if (found_node)
return found_node
return None
snapshot = page.accessibility.snapshot()
@ -153,4 +156,4 @@ Prune uninteresting nodes from the tree. Defaults to `true`.
### option: Accessibility.snapshot.root
- `root` <[ElementHandle]>
The root DOM element for the snapshot. Defaults to the whole page.
The root DOM element for the snapshot. Defaults to the whole page.

View file

@ -10661,7 +10661,8 @@ export interface Accessibility {
* return node;
* for (const child of node.children || []) {
* const foundNode = findFocusedNode(child);
* return foundNode;
* if (foundNode)
* return foundNode;
* }
* return null;
* }