From 6bb076010ef8d7d0163e0e2ce7b923159a9d2dbe Mon Sep 17 00:00:00 2001 From: zsmj1994 Date: Tue, 16 Mar 2021 16:42:15 +0800 Subject: [PATCH] =?UTF-8?q?DEC-17509=20fix:=20getSearchResult=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=98=AF=E5=90=A6=E9=9C=80=E8=A6=81deepClone=E5=B1=9E?= =?UTF-8?q?=E6=80=A7,=E6=8F=90=E5=8D=87=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/func/function.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/func/function.js b/src/core/func/function.js index 731fd54996..05c8fe78aa 100644 --- a/src/core/func/function.js +++ b/src/core/func/function.js @@ -15,8 +15,8 @@ _.extend(BI.Func, { name = name || ""; while (true) { if (BI.every(array, function (i, item) { - return BI.isKey(item) ? item !== name : item.name !== name; - })) { + return BI.isKey(item) ? item !== name : item.name !== name; + })) { break; } name = src + (idx++); @@ -40,14 +40,16 @@ _.extend(BI.Func, { * @param items * @param keyword * @param param 搜索哪个属性 + * @param clone 是否需要deepClone */ - getSearchResult: function (items, keyword, param) { + getSearchResult: function (items, keyword, param, clone) { var isArray = BI.isArray(items); items = isArray ? BI.flatten(items) : items; param || (param = "text"); + BI.isNull(clone) && (clone = true); if (!BI.isKey(keyword)) { return { - find: BI.deepClone(items), + find: clone ? BI.deepClone(items) : items, match: isArray ? [] : {} }; } @@ -59,7 +61,7 @@ _.extend(BI.Func, { if (BI.isNull(item)) { return; } - item = BI.deepClone(item); + clone && (item = BI.deepClone(item)); t = BI.stripEL(item); text = BI.find([t[param], t.text, t.value, t.name, t], function (index, val) { return BI.isNotNull(val);