From 1a853135f4e46d39bc2e114c3fde47cfe65fc5fb Mon Sep 17 00:00:00 2001 From: dailer Date: Thu, 9 May 2019 17:23:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=20BI.Text?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=9C=A8mouted=E4=B8=ADsetText=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91,=E6=8F=90=E9=AB=98=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/single/text.js | 16 +++++++--------- src/core/alias.js | 21 ++++++++------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/base/single/text.js b/src/base/single/text.js index 0a1f9c306..0c224d9c8 100644 --- a/src/base/single/text.js +++ b/src/base/single/text.js @@ -55,7 +55,7 @@ BI.Text = BI.inherit(BI.Single, { this.element.css({ textAlign: o.textAlign, whiteSpace: o.whiteSpace, - textOverflow: o.whiteSpace === 'nowrap' ? "ellipsis" : "", + textOverflow: o.whiteSpace === "nowrap" ? "ellipsis" : "" }); if (o.handler) { this.text = BI.createWidget({ @@ -73,15 +73,7 @@ BI.Text = BI.inherit(BI.Single, { } else { this.text = this; } - }, - _getShowText: function () { - var o = this.options; - return BI.isFunction(o.text) ? o.text() : o.text; - }, - - mounted: function () { - var o = this.options; var text = this._getShowText(); if (BI.isKey(text)) { this.setText(text); @@ -96,6 +88,12 @@ BI.Text = BI.inherit(BI.Single, { } }, + _getShowText: function () { + var o = this.options; + return BI.isFunction(o.text) ? o.text() : o.text; + }, + + doRedMark: function (keyword) { var o = this.options; // render之后做的doredmark,这个时候虽然标红了,但是之后text mounted执行的时候并没有keyword diff --git a/src/core/alias.js b/src/core/alias.js index da396cc31..4f332f2da 100644 --- a/src/core/alias.js +++ b/src/core/alias.js @@ -411,21 +411,16 @@ }; // replace the html special tags + var specialTags = { + "&": "&", + "\"": """, + "<": "<", + ">": ">", + " ": " " + }; BI.htmlEncode = function (text) { return BI.isNull(text) ? "" : BI.replaceAll(text + "", "&|\"|<|>|\\s", function (v) { - switch (v) { - case "&": - return "&"; - case "\"": - return """; - case "<": - return "<"; - case ">": - return ">"; - case " ": - default: - return " "; - } + return specialTags[v] ? specialTags[v] : " "; }); }; // html decode