From ab39cfcb184515db2df7cd3542fe023435e5d2b1 Mon Sep 17 00:00:00 2001 From: Andrew Hayward Date: Wed, 23 Mar 2022 10:50:35 +0000 Subject: [PATCH] docs: fixing example code in accessibility API docs (#12664) Co-authored-by: Andrey Lushnikov --- docs/src/api/class-accessibility.md | 11 +++++++---- packages/playwright-core/types/types.d.ts | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/src/api/class-accessibility.md b/docs/src/api/class-accessibility.md index a7d6b11d23..f2c0c03171 100644 --- a/docs/src/api/class-accessibility.md +++ b/docs/src/api/class-accessibility.md @@ -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. \ No newline at end of file +The root DOM element for the snapshot. Defaults to the whole page. diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts index 4fddaf3930..34d8be250f 100644 --- a/packages/playwright-core/types/types.d.ts +++ b/packages/playwright-core/types/types.d.ts @@ -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; * }