text: optimize value update when there's no icon to draw

This commit is contained in:
bordun 2020-01-28 16:32:47 +01:00
parent 92c6f15fab
commit acf90ff0ca
2 changed files with 8 additions and 1 deletions

View file

@ -12,6 +12,7 @@
- widgets:
- **new** `menu` widget, circular alternative to the dropdown & switch widgets
- file: allow selecting folders
- text: optimize value update when there's no icon to draw
- editor:
- convert invalid quote characters automatically to avoid errors

View file

@ -57,7 +57,13 @@ module.exports = class Text extends Widget {
setValue(v, options={}) {
this.value = v==null ? this.defaultValue : v
this.widget.innerHTML = iconify(String(this.value).replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>'))
var s = String(this.value)
if (s.indexOf('^') > -1) {
this.widget.innerHTML = iconify(s.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>'))
} else {
this.widget.textContent = s.replace(/\n/g,'\r\n')
}
if (options.sync) this.changed(options)