From a7db8e15b3fcb44197d6237c93ccbcca41b6b041 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 3 Sep 2020 18:16:38 +0800 Subject: [PATCH 1/4] bugfix --- src/base/single/text.js | 17 ++++++----------- src/core/platform/web/jquery/fn.js | 7 ++++++- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/base/single/text.js b/src/base/single/text.js index 00eb774cd..5449eaefe 100644 --- a/src/base/single/text.js +++ b/src/base/single/text.js @@ -104,21 +104,22 @@ _getShowText: function () { var o = this.options; - return BI.isFunction(o.text) ? o.text() : o.text; + var text = BI.isFunction(o.text) ? o.text() : o.text; + text = BI.isKey(text) ? text : o.value; + return BI.Text.formatText(text + ""); }, - doRedMark: function (keyword) { var o = this.options; // render之后做的doredmark,这个时候虽然标红了,但是之后text mounted执行的时候并没有keyword o.keyword = keyword; - this.text.element.__textKeywordMarked__(this._getShowText() || o.value, keyword, o.py); + this.text.element.__textKeywordMarked__(this._getShowText(), keyword, o.py); }, unRedMark: function () { var o = this.options; o.keyword = ""; - this.text.element.__textKeywordMarked__(this._getShowText() || o.value, "", o.py); + this.text.element.__textKeywordMarked__(this._getShowText(), "", o.py); }, doHighLight: function () { @@ -144,13 +145,7 @@ BI.Text.superclass.setText.apply(this, arguments); // 为textContext赋值为undefined时在ie和edge下会真的显示undefined this.options.text = BI.isNotNull(text) ? text : ""; - if (BI.isIE9Below()) { - this.text.element.html(BI.htmlEncode(BI.Text.formatText(this._getShowText()))); - return; - } - // textContent性能更好,并且原生防xss - this.text.element[0].textContent = BI.Text.formatText(this._getShowText()); - BI.isKey(this.options.keyword) && this.doRedMark(this.options.keyword); + this.doRedMark(this.options.keyword); } }); var formatters = []; diff --git a/src/core/platform/web/jquery/fn.js b/src/core/platform/web/jquery/fn.js index 397f1408f..4d95e67a7 100644 --- a/src/core/platform/web/jquery/fn.js +++ b/src/core/platform/web/jquery/fn.js @@ -78,7 +78,12 @@ if (BI.jQuery) { */ __textKeywordMarked__: function (text, keyword, py) { if (!BI.isKey(keyword) || (text + "").length > 100) { - return this.html(BI.htmlEncode(text)); + if (BI.isIE9Below()) { + return this.html(BI.htmlEncode(text)); + } + // textContent性能更好,并且原生防xss + this[0].textContent = text; + return this; } keyword = keyword + ""; keyword = BI.toUpperCase(keyword); From 157790771cea749adefac90d5a3b6d87e572aa9e Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 3 Sep 2020 18:21:36 +0800 Subject: [PATCH 2/4] bugfix --- src/base/single/text.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/base/single/text.js b/src/base/single/text.js index 5449eaefe..67f8f97c7 100644 --- a/src/base/single/text.js +++ b/src/base/single/text.js @@ -109,13 +109,19 @@ return BI.Text.formatText(text + ""); }, - doRedMark: function (keyword) { + _doRedMark: function (keyword) { var o = this.options; // render之后做的doredmark,这个时候虽然标红了,但是之后text mounted执行的时候并没有keyword o.keyword = keyword; this.text.element.__textKeywordMarked__(this._getShowText(), keyword, o.py); }, + doRedMark: function (keyword) { + if (BI.isKey(this.options.keyword)) { + this._doRedMark(keyword); + } + }, + unRedMark: function () { var o = this.options; o.keyword = ""; @@ -145,7 +151,7 @@ BI.Text.superclass.setText.apply(this, arguments); // 为textContext赋值为undefined时在ie和edge下会真的显示undefined this.options.text = BI.isNotNull(text) ? text : ""; - this.doRedMark(this.options.keyword); + this._doRedMark(this.options.keyword); } }); var formatters = []; From 098b93ce134c43d321a4ccdec319068eb1eee772 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 3 Sep 2020 18:22:28 +0800 Subject: [PATCH 3/4] bugfix --- src/base/single/text.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/single/text.js b/src/base/single/text.js index 67f8f97c7..f0cb1b332 100644 --- a/src/base/single/text.js +++ b/src/base/single/text.js @@ -118,7 +118,7 @@ doRedMark: function (keyword) { if (BI.isKey(this.options.keyword)) { - this._doRedMark(keyword); + this._doRedMark(this.options.keyword); } }, From a7281f4462cce76899f498fd4da2545ac7eb15aa Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 3 Sep 2020 18:23:52 +0800 Subject: [PATCH 4/4] bugfix --- src/base/single/text.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/base/single/text.js b/src/base/single/text.js index f0cb1b332..bc316725d 100644 --- a/src/base/single/text.js +++ b/src/base/single/text.js @@ -117,8 +117,8 @@ }, doRedMark: function (keyword) { - if (BI.isKey(this.options.keyword)) { - this._doRedMark(this.options.keyword); + if (BI.isKey(keyword)) { + this._doRedMark(keyword); } },