From 4687f499ef1b8e79759d2eec479ba368a2f56d81 Mon Sep 17 00:00:00 2001 From: innovational <1028932693@qq.com> Date: Thu, 7 Sep 2023 16:18:02 +0800 Subject: [PATCH] Update create-selector-query.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复当dom 不存在时会报错的问题 --- .../service/api/ui/create-selector-query.js | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/core/service/api/ui/create-selector-query.js b/src/core/service/api/ui/create-selector-query.js index 37c6fe4ffd8..8fd0e5aa9d4 100644 --- a/src/core/service/api/ui/create-selector-query.js +++ b/src/core/service/api/ui/create-selector-query.js @@ -98,17 +98,19 @@ class SelectorQuery { exec (callback) { invokeMethod('requestComponentInfo', this._page, this._queue, res => { const queueCbs = this._queueCb - res.forEach((result, index) => { - if (Array.isArray(result)) { - result.forEach(convertContext) - } else { - convertContext(result) - } - const queueCb = queueCbs[index] - if (isFn(queueCb)) { - queueCb.call(this, result) - } - }) + if(res && res.length) { + res.forEach((result, index) => { + if (Array.isArray(result)) { + result.forEach(convertContext) + } else { + convertContext(result) + } + const queueCb = queueCbs[index] + if (isFn(queueCb)) { + queueCb.call(this, result) + } + }) + } isFn(callback) && callback.call(this, res) })