Syncronizes view from model value, fires change events
(cursorPos?: number | 'auto')
| 215 | |
| 216 | /** Syncronizes view from model value, fires change events */ |
| 217 | updateControl (cursorPos?: number | 'auto') { |
| 218 | const newUnmaskedValue = this.masked.unmaskedValue; |
| 219 | const newValue = this.masked.value; |
| 220 | const newRawInputValue = this.masked.rawInputValue; |
| 221 | const newDisplayValue = this.displayValue; |
| 222 | |
| 223 | const isChanged = |
| 224 | this.unmaskedValue !== newUnmaskedValue || |
| 225 | this.value !== newValue || |
| 226 | this._rawInputValue !== newRawInputValue |
| 227 | ; |
| 228 | |
| 229 | this._unmaskedValue = newUnmaskedValue; |
| 230 | this._value = newValue; |
| 231 | this._rawInputValue = newRawInputValue; |
| 232 | |
| 233 | if (this.el.value !== newDisplayValue) this.el.value = newDisplayValue; |
| 234 | |
| 235 | if (cursorPos === 'auto') this.alignCursor(); |
| 236 | else if (cursorPos != null) this.cursorPos = cursorPos; |
| 237 | |
| 238 | if (isChanged) this._fireChangeEvents(); |
| 239 | if (!this._historyChanging && (isChanged || this.history.isEmpty)) this.history.push({ |
| 240 | unmaskedValue: newUnmaskedValue, |
| 241 | selection: { start: this.selectionStart, end: this.cursorPos }, |
| 242 | }); |
| 243 | } |
| 244 | |
| 245 | /** Updates options with deep equal check, recreates {@link Masked} model if mask type changes */ |
| 246 | updateOptions(opts: UpdateOpts<Opts>) { |
no test coverage detected