fix: getDescendants isEmpty removeLast error

This commit is contained in:
lisonge 2023-11-07 18:59:50 +08:00
parent 950b6e6b4b
commit 05ddbb23ce
2 changed files with 2 additions and 0 deletions

View File

@ -149,6 +149,7 @@ val abTransform = Transform(
getDescendants = { node ->
sequence {
val stack = getChildren(node).toMutableList()
if (stack.isEmpty()) return@sequence
val tempNodes = mutableListOf<AccessibilityNodeInfo>()
do {
val top = stack.removeLast()

View File

@ -53,6 +53,7 @@ class Transform<T>(
sequence { // 深度优先 先序遍历
// https://developer.mozilla.org/zh-CN/docs/Web/API/Document/querySelector
val stack = getChildren(node).toMutableList()
if (stack.isEmpty()) return@sequence
stack.reverse()
val tempNodes = mutableListOf<T>()
do {