From 9e2d3a92c0143e1bb672a1840a576166b8600866 Mon Sep 17 00:00:00 2001 From: git Date: Thu, 17 Jun 2021 22:55:33 +0800 Subject: [PATCH 1/6] bugfix --- src/base/single/1.text.js | 6 +++--- src/core/platform/web/jquery/fn.js | 15 +++++++++++++-- .../trigger/searcher.multiselect.insert.js | 8 ++++---- .../multiselect/trigger/searcher.multiselect.js | 8 ++++---- .../multitree/trigger/searcher.list.multi.tree.js | 2 +- .../multitree/trigger/searcher.multi.tree.js | 4 ++-- 6 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/base/single/1.text.js b/src/base/single/1.text.js index f7925d5fe..1baae987f 100644 --- a/src/base/single/1.text.js +++ b/src/base/single/1.text.js @@ -77,6 +77,7 @@ } var text = this._getShowText(); + // 只要不是undefined就可以显示text值,否则显示value if (!BI.isUndefined(text)) { this.setText(text); } else if (BI.isKey(o.value)) { @@ -111,7 +112,7 @@ _doRedMark: function (keyword) { var o = this.options; - // render之后做的doredmark,这个时候虽然标红了,但是之后text mounted执行的时候并没有keyword + // render之后做的doRedMark,这个时候虽然标红了,但是之后text mounted执行的时候并没有keyword o.keyword = keyword; this.text.element.__textKeywordMarked__(this._getShowText(), keyword, o.py); }, @@ -149,8 +150,7 @@ setText: function (text) { BI.Text.superclass.setText.apply(this, arguments); - // 为textContext赋值为undefined时在ie和edge下会真的显示undefined - this.options.text = BI.isNotNull(text) ? text : ""; + this.options.text = text; this._doRedMark(this.options.keyword); } }); diff --git a/src/core/platform/web/jquery/fn.js b/src/core/platform/web/jquery/fn.js index 4d95e67a7..d484c0cea 100644 --- a/src/core/platform/web/jquery/fn.js +++ b/src/core/platform/web/jquery/fn.js @@ -77,17 +77,28 @@ if (BI.jQuery) { * 3、text和py各自取tidx/pidx + keyword.length索引开始的子串作为新的text和py, 重复1, 直到text和py有一个为"" */ __textKeywordMarked__: function (text, keyword, py) { + if (text === null) { + if (BI.isIE9Below()) { + return this.html("(null)"); + } + // textContent性能更好,并且原生防xss + this[0].textContent = "(null)"; + return this; + } + if (BI.isUndefined(text)) { + text = ""; + } if (!BI.isKey(keyword) || (text + "").length > 100) { if (BI.isIE9Below()) { return this.html(BI.htmlEncode(text)); } - // textContent性能更好,并且原生防xss + // textContent性能更好,并且原生防xss this[0].textContent = text; return this; } keyword = keyword + ""; keyword = BI.toUpperCase(keyword); - var textLeft = (text || "") + ""; + var textLeft = text + ""; py = (py || BI.makeFirstPY(text, { splitChar: "\u200b" })) + ""; diff --git a/src/widget/multiselect/trigger/searcher.multiselect.insert.js b/src/widget/multiselect/trigger/searcher.multiselect.insert.js index e055f86f8..3d6285222 100644 --- a/src/widget/multiselect/trigger/searcher.multiselect.insert.js +++ b/src/widget/multiselect/trigger/searcher.multiselect.insert.js @@ -135,9 +135,9 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, { var state = ""; BI.each(ob.assist, function (i, v) { if (i === 0) { - state += "" + (v === null ? "" : (o.valueFormatter(v + "") || v)); + state += "" + (v === null ? "(null)" : (o.valueFormatter(v + "") || v)); } else { - state += "," + (v === null ? "" : (o.valueFormatter(v + "") || v)); + state += "," + (v === null ? "(null)" : (o.valueFormatter(v + "") || v)); } }); this.editor.setState(state); @@ -151,9 +151,9 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, { var state = ""; BI.each(ob.value, function (i, v) { if (i === 0) { - state += "" + (v === null ? "" : (o.valueFormatter(v + "") || v)); + state += "" + (v === null ? "(null)" : (o.valueFormatter(v + "") || v)); } else { - state += "," + (v === null ? "" : (o.valueFormatter(v + "") || v)); + state += "," + (v === null ? "(null)" : (o.valueFormatter(v + "") || v)); } }); this.editor.setState(state); diff --git a/src/widget/multiselect/trigger/searcher.multiselect.js b/src/widget/multiselect/trigger/searcher.multiselect.js index ec26eccca..d6c7e18f2 100644 --- a/src/widget/multiselect/trigger/searcher.multiselect.js +++ b/src/widget/multiselect/trigger/searcher.multiselect.js @@ -133,9 +133,9 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, { var state = ""; BI.each(ob.assist, function (i, v) { if (i === 0) { - state += "" + (v === null ? "" : (o.valueFormatter(v + "") || v)); + state += "" + (v === null ? "(null)" : (o.valueFormatter(v + "") || v)); } else { - state += "," + (v === null ? "" : (o.valueFormatter(v + "") || v)); + state += "," + (v === null ? "(null)" : (o.valueFormatter(v + "") || v)); } }); this.editor.setState(state); @@ -149,9 +149,9 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, { var state = ""; BI.each(ob.value, function (i, v) { if (i === 0) { - state += "" + (v === null ? "" : (o.valueFormatter(v + "") || v)); + state += "" + (v === null ? "(null)" : (o.valueFormatter(v + "") || v)); } else { - state += "," + (v === null ? "" : (o.valueFormatter(v + "") || v)); + state += "," + (v === null ? "(null)" : (o.valueFormatter(v + "") || v)); } }); this.editor.setState(state); diff --git a/src/widget/multitree/trigger/searcher.list.multi.tree.js b/src/widget/multitree/trigger/searcher.list.multi.tree.js index 2a8d9f4c5..04cabb969 100644 --- a/src/widget/multitree/trigger/searcher.list.multi.tree.js +++ b/src/widget/multitree/trigger/searcher.list.multi.tree.js @@ -122,7 +122,7 @@ BI.MultiListTreeSearcher = BI.inherit(BI.Widget, { var text = ""; BI.each(ob.value, function (idx, path) { var childValue = BI.last(path); - text += (path === "null" ? "" : (o.valueFormatter(childValue + "") || childValue) + "; "); + text += (path === "null" ? "(null)" : (o.valueFormatter(childValue + "") || childValue) + "; "); count++; }); diff --git a/src/widget/multitree/trigger/searcher.multi.tree.js b/src/widget/multitree/trigger/searcher.multi.tree.js index 65738cd2d..bd10a3be0 100644 --- a/src/widget/multitree/trigger/searcher.multi.tree.js +++ b/src/widget/multitree/trigger/searcher.multi.tree.js @@ -136,7 +136,7 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, { var names = BI.Func.getSortedResult(BI.keys(value)); BI.each(names, function (idx, name) { var childNodes = getChildrenNode(value[name]); - text += (name === "null" ? "" : (o.valueFormatter(name + "") || name)) + (childNodes === "" ? "" : (":" + childNodes)) + "; "; + text += (name === "null" ? "(null)" : (o.valueFormatter(name + "") || name)) + (childNodes === "" ? "" : (":" + childNodes)) + "; "; if (childNodes === "") { count++; } @@ -156,7 +156,7 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, { BI.each(names, function (idx, name) { index++; var childNodes = getChildrenNode(ob[name]); - text += (name === "null" ? "" : (o.valueFormatter(name + "") || name)) + (childNodes === "" ? "" : (":" + childNodes)) + (index === size ? "" : ","); + text += (name === "null" ? "(null)" : (o.valueFormatter(name + "") || name)) + (childNodes === "" ? "" : (":" + childNodes)) + (index === size ? "" : ","); if (childNodes === "") { count++; } From b1d2751573d54f33586e695a723df42b93badce2 Mon Sep 17 00:00:00 2001 From: git Date: Thu, 17 Jun 2021 23:02:47 +0800 Subject: [PATCH 2/6] bugfix --- src/case/ztree/0.treeview.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/case/ztree/0.treeview.js b/src/case/ztree/0.treeview.js index e9cb06dd7..fc99a5311 100644 --- a/src/case/ztree/0.treeview.js +++ b/src/case/ztree/0.treeview.js @@ -334,9 +334,14 @@ BI.TreeView = BI.inherit(BI.Pane, { var self = this, o = this.options; var ns = BI.Tree.arrayFormat(nodes); BI.each(ns, function (i, n) { - n.title = n.title || n.text || n.value; n.isParent = n.isParent || n.parent; n.value = BI.isUndefined(n.value) ? n.text : n.value; + if (n.text === null) { + n.text = "(null)"; + } else if(BI.isUndefined(n.text)) { + n.text = ""; + } + n.title = n.title || n.text || n.value; // 处理标红 if (BI.isNotNull(n.text)) { if (BI.isKey(o.paras.keyword)) { @@ -344,8 +349,6 @@ BI.TreeView = BI.inherit(BI.Pane, { } else { n.text = BI.htmlEncode(BI.Text.formatText(n.text + "")); } - } else { - n.text = ""; } }); return nodes; From 68e4655f810a9c0ac98939e7a3e290eae91ca21f Mon Sep 17 00:00:00 2001 From: git Date: Thu, 17 Jun 2021 23:32:51 +0800 Subject: [PATCH 3/6] bugfix --- src/case/ztree/0.treeview.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/case/ztree/0.treeview.js b/src/case/ztree/0.treeview.js index fc99a5311..cefd048c0 100644 --- a/src/case/ztree/0.treeview.js +++ b/src/case/ztree/0.treeview.js @@ -338,10 +338,17 @@ BI.TreeView = BI.inherit(BI.Pane, { n.value = BI.isUndefined(n.value) ? n.text : n.value; if (n.text === null) { n.text = "(null)"; - } else if(BI.isUndefined(n.text)) { + } + if (BI.isNull(n.title)) { + if (BI.isNotNull(n.text)) { + n.title = n.text; + } else { + n.title = n.value; + } + } + if (BI.isUndefined(n.text)) { n.text = ""; } - n.title = n.title || n.text || n.value; // 处理标红 if (BI.isNotNull(n.text)) { if (BI.isKey(o.paras.keyword)) { From 678d03cd13ab2ba4d5af8c49ad5c499a20021b09 Mon Sep 17 00:00:00 2001 From: git Date: Thu, 17 Jun 2021 23:36:58 +0800 Subject: [PATCH 4/6] bugfix --- src/case/ztree/0.treeview.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/case/ztree/0.treeview.js b/src/case/ztree/0.treeview.js index cefd048c0..a54c8f162 100644 --- a/src/case/ztree/0.treeview.js +++ b/src/case/ztree/0.treeview.js @@ -338,16 +338,11 @@ BI.TreeView = BI.inherit(BI.Pane, { n.value = BI.isUndefined(n.value) ? n.text : n.value; if (n.text === null) { n.text = "(null)"; + } else if (BI.isUndefined(n.text)) { + n.text = n.value; } if (BI.isNull(n.title)) { - if (BI.isNotNull(n.text)) { - n.title = n.text; - } else { - n.title = n.value; - } - } - if (BI.isUndefined(n.text)) { - n.text = ""; + n.title = n.text; } // 处理标红 if (BI.isNotNull(n.text)) { From 889c33cb17d89274f3a2e98be69a59cf287e2839 Mon Sep 17 00:00:00 2001 From: git Date: Thu, 17 Jun 2021 23:38:29 +0800 Subject: [PATCH 5/6] bugfix --- src/case/ztree/0.treeview.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/case/ztree/0.treeview.js b/src/case/ztree/0.treeview.js index a54c8f162..c4310caf0 100644 --- a/src/case/ztree/0.treeview.js +++ b/src/case/ztree/0.treeview.js @@ -336,10 +336,11 @@ BI.TreeView = BI.inherit(BI.Pane, { BI.each(ns, function (i, n) { n.isParent = n.isParent || n.parent; n.value = BI.isUndefined(n.value) ? n.text : n.value; + if (BI.isUndefined(n.text)) { + n.text = n.value; + } if (n.text === null) { n.text = "(null)"; - } else if (BI.isUndefined(n.text)) { - n.text = n.value; } if (BI.isNull(n.title)) { n.title = n.text; From 8fc440f1ce25249aae216f5980e4cf133bfcf54b Mon Sep 17 00:00:00 2001 From: git Date: Thu, 17 Jun 2021 23:43:22 +0800 Subject: [PATCH 6/6] bugfix --- src/case/ztree/0.treeview.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/case/ztree/0.treeview.js b/src/case/ztree/0.treeview.js index c4310caf0..850f9104c 100644 --- a/src/case/ztree/0.treeview.js +++ b/src/case/ztree/0.treeview.js @@ -336,9 +336,7 @@ BI.TreeView = BI.inherit(BI.Pane, { BI.each(ns, function (i, n) { n.isParent = n.isParent || n.parent; n.value = BI.isUndefined(n.value) ? n.text : n.value; - if (BI.isUndefined(n.text)) { - n.text = n.value; - } + n.text = BI.isUndefined(n.text) ? n.value : n.text; if (n.text === null) { n.text = "(null)"; }