From 363e544563c553ee5be3b181fb4d738ac8a5b47a Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 6 Dec 2019 10:39:06 +0800 Subject: [PATCH 1/5] =?UTF-8?q?BI-56945=20hidden=20danger:=20=E5=95=8Aa?= =?UTF-8?q?=E6=A0=87=E7=BA=A2=E5=80=BC=E6=A0=87=E7=BA=A2=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=20&&=20=E5=8D=95=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform/web/jquery/__test__/fn.test.js | 64 +++++++++++++++++++ src/core/platform/web/jquery/fn.js | 3 +- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/core/platform/web/jquery/__test__/fn.test.js diff --git a/src/core/platform/web/jquery/__test__/fn.test.js b/src/core/platform/web/jquery/__test__/fn.test.js new file mode 100644 index 000000000..6c23271fd --- /dev/null +++ b/src/core/platform/web/jquery/__test__/fn.test.js @@ -0,0 +1,64 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2019/12/6 + */ + +describe("标红test", function () { + + /** + * test_author_windy + */ + it("无多音字标红", function () { + var a = BI.Test.createWidget({ + type: "bi.layout", + }); + a.element.__textKeywordMarked__("无多音字", "w"); + expect(a.element.html()).to.equal("多音字"); + a.destroy(); + }); + + /** + * test_author_windy + */ + it("含有多音字标红", function () { + var a = BI.Test.createWidget({ + type: "bi.layout", + }); + a.element.__textKeywordMarked__("长期协议", "z"); + expect(a.element.html()).to.equal("期协议"); + a.element.__textKeywordMarked__("长期协议", "c"); + expect(a.element.html()).to.equal("期协议"); + a.destroy(); + }); + + /** + * test_author_windy + */ + it("多音字错位标红", function () { + var a = BI.Test.createWidget({ + type: "bi.layout", + }); + a.element.__textKeywordMarked__("呵呵呵", "h"); + expect(a.element.html()).to.equal(""); + a.element.__textKeywordMarked__("呵呵呵", "hh"); + expect(a.element.html()).to.equal("呵呵呵"); + a.element.__textKeywordMarked__("呵呵呵", "hhh"); + expect(a.element.html()).to.equal("呵呵呵"); + a.destroy(); + }); + + /** + * test_author_windy + */ + it("原文和拼音都匹配标红", function () { + var a = BI.Test.createWidget({ + type: "bi.layout", + }); + a.element.__textKeywordMarked__("啊a", "a"); + expect(a.element.html()).to.equal("a"); + a.element.__textKeywordMarked__("a啊", "a"); + expect(a.element.html()).to.equal("a"); + a.destroy(); + }); +}); \ No newline at end of file diff --git a/src/core/platform/web/jquery/fn.js b/src/core/platform/web/jquery/fn.js index 9d94719c6..4798e90af 100644 --- a/src/core/platform/web/jquery/fn.js +++ b/src/core/platform/web/jquery/fn.js @@ -98,7 +98,8 @@ if (BI.jQuery) { } } - if (tidx >= 0) { + // BI-56945 场景: 对'啊a'标红, a为keyword, 此时tidx为1, pidx为0, 此时使用tidx显然'啊'就无法标红了 + if (tidx >= 0 && pidx > tidx) { // 标红的text未encode this.append(BI.htmlEncode(textLeft.substr(0, tidx))); this.append(BI.$("").addClass("bi-keyword-red-mark") From 591df8865aef299aecf58a3382a8156d4d4ea7b4 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 6 Dec 2019 10:46:22 +0800 Subject: [PATCH 2/5] update --- src/core/platform/web/jquery/fn.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/platform/web/jquery/fn.js b/src/core/platform/web/jquery/fn.js index 4798e90af..341719b54 100644 --- a/src/core/platform/web/jquery/fn.js +++ b/src/core/platform/web/jquery/fn.js @@ -99,7 +99,7 @@ if (BI.jQuery) { } // BI-56945 场景: 对'啊a'标红, a为keyword, 此时tidx为1, pidx为0, 此时使用tidx显然'啊'就无法标红了 - if (tidx >= 0 && pidx > tidx) { + if (tidx >= 0 && BI.isNotNull(pidx) && pidx > tidx) { // 标红的text未encode this.append(BI.htmlEncode(textLeft.substr(0, tidx))); this.append(BI.$("").addClass("bi-keyword-red-mark") From 3cdb12095bb771ece657c13357889b83ba625e6e Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 6 Dec 2019 17:21:12 +0800 Subject: [PATCH 3/5] =?UTF-8?q?REPORT-24923=20&&=20REPORT-24867=20fix:=20?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E6=8E=A7=E4=BB=B6=E4=B8=8B=E6=8B=89=E6=94=B6?= =?UTF-8?q?=E8=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/dynamicdate/dynamicdate.combo.js | 1 + src/widget/dynamicdate/dynamicdate.popup.js | 4 ++-- src/widget/dynamicdatetime/dynamicdatetime.combo.js | 1 + src/widget/dynamicdatetime/dynamicdatetime.popup.js | 4 ++-- src/widget/yearmonth/card.static.yearmonth.js | 4 ++-- src/widget/yearmonth/popup.yearmonth.js | 4 ++-- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/widget/dynamicdate/dynamicdate.combo.js b/src/widget/dynamicdate/dynamicdate.combo.js index d659a3eee..d12dc03fc 100644 --- a/src/widget/dynamicdate/dynamicdate.combo.js +++ b/src/widget/dynamicdate/dynamicdate.combo.js @@ -46,6 +46,7 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, { toggle: false, isNeedAdjustHeight: false, isNeedAdjustWidth: false, + destroyWhenHide: true, el: { type: "bi.dynamic_date_trigger", min: opts.minDate, diff --git a/src/widget/dynamicdate/dynamicdate.popup.js b/src/widget/dynamicdate/dynamicdate.popup.js index b862db0fb..73abd0b1a 100644 --- a/src/widget/dynamicdate/dynamicdate.popup.js +++ b/src/widget/dynamicdate/dynamicdate.popup.js @@ -173,16 +173,16 @@ BI.DynamicDatePopup = BI.inherit(BI.Widget, { setMinDate: function (minDate) { if (this.options.min !== minDate) { + this.options.min = minDate; this.ymd.setMinDate(minDate); } - this.options.min = minDate; }, setMaxDate: function (maxDate) { if (this.options.max !== maxDate) { + this.options.max = maxDate; this.ymd.setMaxDate(maxDate); } - this.options.max = maxDate; }, setValue: function (v) { diff --git a/src/widget/dynamicdatetime/dynamicdatetime.combo.js b/src/widget/dynamicdatetime/dynamicdatetime.combo.js index 95f655433..27d2b9520 100644 --- a/src/widget/dynamicdatetime/dynamicdatetime.combo.js +++ b/src/widget/dynamicdatetime/dynamicdatetime.combo.js @@ -39,6 +39,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { items: [{ el: { type: "bi.combo", + destroyWhenHide: true, container: opts.container, ref: function () { self.combo = this; diff --git a/src/widget/dynamicdatetime/dynamicdatetime.popup.js b/src/widget/dynamicdatetime/dynamicdatetime.popup.js index d8f943551..f98c57959 100644 --- a/src/widget/dynamicdatetime/dynamicdatetime.popup.js +++ b/src/widget/dynamicdatetime/dynamicdatetime.popup.js @@ -180,16 +180,16 @@ BI.DynamicDateTimePopup = BI.inherit(BI.Widget, { setMinDate: function (minDate) { if (this.options.min !== minDate) { + this.options.min = minDate; this.ymd.setMinDate(minDate); } - this.options.min = minDate; }, setMaxDate: function (maxDate) { if (this.options.max !== maxDate) { + this.options.max = maxDate; this.ymd.setMaxDate(maxDate); } - this.options.max = maxDate; }, setValue: function (v) { diff --git a/src/widget/yearmonth/card.static.yearmonth.js b/src/widget/yearmonth/card.static.yearmonth.js index 24a2f2ff4..740dcf6d1 100644 --- a/src/widget/yearmonth/card.static.yearmonth.js +++ b/src/widget/yearmonth/card.static.yearmonth.js @@ -115,18 +115,18 @@ BI.StaticYearMonthCard = BI.inherit(BI.Widget, { setMinDate: function (minDate) { if (this.options.min !== minDate) { + this.options.min = minDate; this.yearPicker.setMinDate(minDate); this._checkMonthStatus(this.selectedYear); } - this.options.min = minDate; }, setMaxDate: function (maxDate) { if (this.options.max !== maxDate) { + this.options.max = maxDate; this.yearPicker.setMaxDate(maxDate); this._checkMonthStatus(this.selectedYear); } - this.options.max = maxDate; }, getValue: function () { diff --git a/src/widget/yearmonth/popup.yearmonth.js b/src/widget/yearmonth/popup.yearmonth.js index d8559b1b7..6c874b2b3 100644 --- a/src/widget/yearmonth/popup.yearmonth.js +++ b/src/widget/yearmonth/popup.yearmonth.js @@ -172,16 +172,16 @@ BI.DynamicYearMonthPopup = BI.inherit(BI.Widget, { setMinDate: function (minDate) { if (this.options.min !== minDate) { + this.options.min = minDate; this.year.setMinDate(minDate); } - this.options.min = minDate; }, setMaxDate: function (maxDate) { if (this.options.max !== maxDate) { + this.options.max = maxDate; this.year.setMaxDate(maxDate); } - this.options.max = maxDate; }, setValue: function (v) { From c50360787a38ae69eadc5431603a7cc5277f627c Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 6 Dec 2019 17:23:05 +0800 Subject: [PATCH 4/5] revert: fn --- src/core/platform/web/jquery/fn.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/platform/web/jquery/fn.js b/src/core/platform/web/jquery/fn.js index 341719b54..9d94719c6 100644 --- a/src/core/platform/web/jquery/fn.js +++ b/src/core/platform/web/jquery/fn.js @@ -98,8 +98,7 @@ if (BI.jQuery) { } } - // BI-56945 场景: 对'啊a'标红, a为keyword, 此时tidx为1, pidx为0, 此时使用tidx显然'啊'就无法标红了 - if (tidx >= 0 && BI.isNotNull(pidx) && pidx > tidx) { + if (tidx >= 0) { // 标红的text未encode this.append(BI.htmlEncode(textLeft.substr(0, tidx))); this.append(BI.$("").addClass("bi-keyword-red-mark") From ea7bc9fc5a32f93525c22d2f0a08c2c33743d0c5 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 6 Dec 2019 17:23:37 +0800 Subject: [PATCH 5/5] revert: test --- .../platform/web/jquery/__test__/fn.test.js | 64 ------------------- 1 file changed, 64 deletions(-) delete mode 100644 src/core/platform/web/jquery/__test__/fn.test.js diff --git a/src/core/platform/web/jquery/__test__/fn.test.js b/src/core/platform/web/jquery/__test__/fn.test.js deleted file mode 100644 index 6c23271fd..000000000 --- a/src/core/platform/web/jquery/__test__/fn.test.js +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @author windy - * @version 2.0 - * Created by windy on 2019/12/6 - */ - -describe("标红test", function () { - - /** - * test_author_windy - */ - it("无多音字标红", function () { - var a = BI.Test.createWidget({ - type: "bi.layout", - }); - a.element.__textKeywordMarked__("无多音字", "w"); - expect(a.element.html()).to.equal("多音字"); - a.destroy(); - }); - - /** - * test_author_windy - */ - it("含有多音字标红", function () { - var a = BI.Test.createWidget({ - type: "bi.layout", - }); - a.element.__textKeywordMarked__("长期协议", "z"); - expect(a.element.html()).to.equal("期协议"); - a.element.__textKeywordMarked__("长期协议", "c"); - expect(a.element.html()).to.equal("期协议"); - a.destroy(); - }); - - /** - * test_author_windy - */ - it("多音字错位标红", function () { - var a = BI.Test.createWidget({ - type: "bi.layout", - }); - a.element.__textKeywordMarked__("呵呵呵", "h"); - expect(a.element.html()).to.equal(""); - a.element.__textKeywordMarked__("呵呵呵", "hh"); - expect(a.element.html()).to.equal("呵呵呵"); - a.element.__textKeywordMarked__("呵呵呵", "hhh"); - expect(a.element.html()).to.equal("呵呵呵"); - a.destroy(); - }); - - /** - * test_author_windy - */ - it("原文和拼音都匹配标红", function () { - var a = BI.Test.createWidget({ - type: "bi.layout", - }); - a.element.__textKeywordMarked__("啊a", "a"); - expect(a.element.html()).to.equal("a"); - a.element.__textKeywordMarked__("a啊", "a"); - expect(a.element.html()).to.equal("a"); - a.destroy(); - }); -}); \ No newline at end of file