MCPcopy
hub / github.com/uNmAnNeR/imaskjs / updateControl

Method updateControl

packages/imask/src/controls/input.ts:217–243  ·  view source on GitHub ↗

Syncronizes view from model value, fires change events

(cursorPos?: number | 'auto')

Source from the content-addressed store, hash-verified

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>) {

Callers 7

valueMethod · 0.95
unmaskedValueMethod · 0.95
rawInputValueMethod · 0.95
typedValueMethod · 0.95
updateOptionsMethod · 0.95
_onInputMethod · 0.95
_onChangeMethod · 0.95

Calls 3

alignCursorMethod · 0.95
_fireChangeEventsMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected