From fcca3f4e1dfe31380ec773ec7f4b8cf4fcb46aa1 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 5 Jun 2020 16:20:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20refactor:?= =?UTF-8?q?=20replaceAll=E5=85=BC=E5=AE=B9null?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/func/__test__/string.test.js | 19 +++++++++++++++++++ src/core/func/string.js | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/core/func/__test__/string.test.js diff --git a/src/core/func/__test__/string.test.js b/src/core/func/__test__/string.test.js new file mode 100644 index 000000000..94ecb9932 --- /dev/null +++ b/src/core/func/__test__/string.test.js @@ -0,0 +1,19 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/6/5 + */ +describe("dateFunctionTest", function () { + + before(function () { + + }); + + /** + * test_author_windy + */ + it("getWeekNumber", function () { + expect(BI.replaceAll(null, "A", "b")).to.equal(null); + expect(BI.replaceAll("A", "A", "b")).to.equal("b"); + }); +}); \ No newline at end of file diff --git a/src/core/func/string.js b/src/core/func/string.js index a480b1ee3..c2d5aeb14 100644 --- a/src/core/func/string.js +++ b/src/core/func/string.js @@ -81,7 +81,7 @@ _.extend(BI, { * @returns {String} 替换后的字符串 */ replaceAll: function (str, s1, s2) { - return str.replace(new RegExp(s1, "gm"), s2); + return BI.isNull(str) ? str : str.replace(new RegExp(s1, "gm"), s2); }, /** * 总是让字符串以指定的字符开头 From 2124feb089778e8b5ba38544979512c8c9cd1995 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 5 Jun 2020 18:01:13 +0800 Subject: [PATCH 2/2] update --- src/component/allvaluechooser/combo.allvaluechooser.js | 2 +- .../allvalue.multitextvalue.combo.js | 2 +- src/component/valuechooser/combo.valuechooser.insert.js | 2 +- src/component/valuechooser/combo.valuechooser.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/component/allvaluechooser/combo.allvaluechooser.js b/src/component/allvaluechooser/combo.allvaluechooser.js index c75b7000f..fa9b5bcbf 100644 --- a/src/component/allvaluechooser/combo.allvaluechooser.js +++ b/src/component/allvaluechooser/combo.allvaluechooser.js @@ -62,7 +62,7 @@ BI.AllValueChooserCombo = BI.inherit(BI.AbstractAllValueChooser, { populate: function (items) { // 直接用combo的populate不会作用到AbstractValueChooser上 this.items = items; - this.combo.populate.apply(this, arguments); + this.combo.populate.apply(this.combo, arguments); } }); BI.AllValueChooserCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; diff --git a/src/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.js b/src/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.js index 544fe5651..213d56ff7 100644 --- a/src/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.js +++ b/src/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.js @@ -51,7 +51,7 @@ BI.AllValueMultiTextValueCombo = BI.inherit(BI.Widget, { populate: function (items) { this.options.items = items; - this.combo.populate.apply(this, arguments); + this.combo.populate.apply(this.combo, arguments); }, _digestValue: function (v) { diff --git a/src/component/valuechooser/combo.valuechooser.insert.js b/src/component/valuechooser/combo.valuechooser.insert.js index 449446605..6696b5feb 100644 --- a/src/component/valuechooser/combo.valuechooser.insert.js +++ b/src/component/valuechooser/combo.valuechooser.insert.js @@ -80,7 +80,7 @@ BI.ValueChooserInsertCombo = BI.inherit(BI.AbstractValueChooser, { populate: function (items) { // 直接用combo的populate不会作用到AbstractValueChooser上 this.items = items; - this.combo.populate.apply(this, arguments); + this.combo.populate.apply(this.combo, arguments); } }); diff --git a/src/component/valuechooser/combo.valuechooser.js b/src/component/valuechooser/combo.valuechooser.js index 00fafcb86..d303f05bc 100644 --- a/src/component/valuechooser/combo.valuechooser.js +++ b/src/component/valuechooser/combo.valuechooser.js @@ -84,7 +84,7 @@ BI.ValueChooserCombo = BI.inherit(BI.AbstractValueChooser, { populate: function (items) { // 直接用combo的populate不会作用到AbstractValueChooser上 this.items = items; - this.combo.populate.apply(this, arguments); + this.combo.populate.apply(this.combo, arguments); } });