From e351830a0cc494bcee8d8a2d6370abf2192ee8ec Mon Sep 17 00:00:00 2001 From: windy Date: Mon, 30 Nov 2020 23:11:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=96=B0=E8=B0=83=E6=95=B4=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 1 + src/base/single/__test__/text.test.js | 38 +++++++++++++++++++++++++ src/base/single/button/button.basic.js | 1 - src/base/single/label/abstract.label.js | 1 - src/base/single/text.js | 10 ++----- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/changelog.md b/changelog.md index d64fa93f2d..0725712a10 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2020-11) +- 修复了文本标签text传递空字符串后显示value值的问题 - 限制了title的最大高度 - bi.textarea_editor添加setWatermark方法 - 生命周期可以通过属性传递来操作 diff --git a/src/base/single/__test__/text.test.js b/src/base/single/__test__/text.test.js index 0aa659ac62..9549b2d7e5 100644 --- a/src/base/single/__test__/text.test.js +++ b/src/base/single/__test__/text.test.js @@ -154,4 +154,42 @@ describe("TextTest", function () { done(); }); }); + + /** + * test_author_windy + */ + it("text的value属性", function () { + var text = BI.Test.createWidget({ + type: "bi.text", + text: "", + value: "aaaa" + }); + expect(text.element.text()).to.equal(""); + text.destroy(); + }); + + /** + * test_author_windy + */ + it("text的value属性1", function () { + var text = BI.Test.createWidget({ + type: "bi.text", + value: "aaaa" + }); + expect(text.element.text()).to.equal("aaaa"); + text.destroy(); + }); + + /** + * test_author_windy + */ + it("text的value属性2", function () { + var text = BI.Test.createWidget({ + type: "bi.text", + text: null, + value: "aaaa" + }); + expect(text.element.text()).to.equal(""); + text.destroy(); + }); }); diff --git a/src/base/single/button/button.basic.js b/src/base/single/button/button.basic.js index 5240f83e07..fb2f87656b 100644 --- a/src/base/single/button/button.basic.js +++ b/src/base/single/button/button.basic.js @@ -11,7 +11,6 @@ BI.BasicButton = BI.inherit(BI.Single, { return BI.extend(conf, { _baseCls: (conf._baseCls || "") + " bi-basic-button" + (conf.invalid ? "" : " cursor-pointer") + ((BI.isIE() && BI.getIEVersion() < 10) ? " hack" : ""), value: "", - text: "", stopEvent: false, stopPropagation: false, selected: false, diff --git a/src/base/single/label/abstract.label.js b/src/base/single/label/abstract.label.js index 2dc09c826f..9bf8b9a200 100644 --- a/src/base/single/label/abstract.label.js +++ b/src/base/single/label/abstract.label.js @@ -17,7 +17,6 @@ rgap: 0, tgap: 0, bgap: 0, - text: "", highLight: false, handler: null }); diff --git a/src/base/single/text.js b/src/base/single/text.js index 823843bfcd..d300c821fe 100644 --- a/src/base/single/text.js +++ b/src/base/single/text.js @@ -18,7 +18,6 @@ rgap: 0, tgap: 0, bgap: 0, - text: "", py: "", highLight: false }, @@ -78,7 +77,7 @@ } var text = this._getShowText(); - if (BI.isKey(text)) { + if (!BI.isUndefined(text)) { this.setText(text); } else if (BI.isKey(o.value)) { this.setText(o.value); @@ -105,11 +104,8 @@ _getShowText: function () { var o = this.options; var text = BI.isFunction(o.text) ? o.text() : o.text; - text = BI.isKey(text) ? text : o.value; - if (!BI.isKey(text)) { - return ""; - } - return BI.Text.formatText(text + ""); + + return BI.isKey(text) ? BI.Text.formatText(text + "") : text; }, _doRedMark: function (keyword) {