Browse Source

无jira任务 BI.Text去掉在mouted中setText的逻辑,提高性能

es6
dailer 5 years ago
parent
commit
1a853135f4
  1. 16
      src/base/single/text.js
  2. 21
      src/core/alias.js

16
src/base/single/text.js

@ -55,7 +55,7 @@ BI.Text = BI.inherit(BI.Single, {
this.element.css({ this.element.css({
textAlign: o.textAlign, textAlign: o.textAlign,
whiteSpace: o.whiteSpace, whiteSpace: o.whiteSpace,
textOverflow: o.whiteSpace === 'nowrap' ? "ellipsis" : "", textOverflow: o.whiteSpace === "nowrap" ? "ellipsis" : ""
}); });
if (o.handler) { if (o.handler) {
this.text = BI.createWidget({ this.text = BI.createWidget({
@ -73,15 +73,7 @@ BI.Text = BI.inherit(BI.Single, {
} else { } else {
this.text = this; 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(); var text = this._getShowText();
if (BI.isKey(text)) { if (BI.isKey(text)) {
this.setText(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) { doRedMark: function (keyword) {
var o = this.options; var o = this.options;
// render之后做的doredmark,这个时候虽然标红了,但是之后text mounted执行的时候并没有keyword // render之后做的doredmark,这个时候虽然标红了,但是之后text mounted执行的时候并没有keyword

21
src/core/alias.js

@ -411,21 +411,16 @@
}; };
// replace the html special tags // replace the html special tags
var specialTags = {
"&": "&",
"\"": """,
"<": "&lt;",
">": "&gt;",
" ": "&nbsp;"
};
BI.htmlEncode = function (text) { BI.htmlEncode = function (text) {
return BI.isNull(text) ? "" : BI.replaceAll(text + "", "&|\"|<|>|\\s", function (v) { return BI.isNull(text) ? "" : BI.replaceAll(text + "", "&|\"|<|>|\\s", function (v) {
switch (v) { return specialTags[v] ? specialTags[v] : "&nbsp;";
case "&":
return "&amp;";
case "\"":
return "&quot;";
case "<":
return "&lt;";
case ">":
return "&gt;";
case " ":
default:
return "&nbsp;";
}
}); });
}; };
// html decode // html decode

Loading…
Cancel
Save