Browse Source

无JIRA任务 优化改用textContent来设置文本.以正则判断的方式判断是否需要htmlEncode,避免使用replaceAll

es6
dailer 6 years ago
parent
commit
e3349682ae
  1. 8
      src/base/single/text.js

8
src/base/single/text.js

@ -129,7 +129,15 @@ BI.Text = BI.inherit(BI.Single, {
setText: function (text) {
BI.Text.superclass.setText.apply(this, arguments);
this.options.text = text;
if (BI.isIE9Below()) {
this.text.element.html(BI.htmlEncode(this._getShowText()));
return;
}
if (/&|\"|<|>|\\s/.test(text)) {
this.text.element[0].textContent = BI.htmlEncode(this._getShowText());
} else {
this.text.element[0].textContent = this._getShowText();
}
}
});

Loading…
Cancel
Save