MCPcopy
hub / github.com/autoNumeric/autoNumeric / _setElementAndRawValue

Method _setElementAndRawValue

src/AutoNumeric.js:2332–2346  ·  view source on GitHub ↗

* Set the given value on the DOM element, and the raw value on `this.rawValue`, if both are given. * If only one value is given, then both the DOM element value and the raw value are set with that value. * The third argument `saveChangeToHistory` defines if the change should be recorded in

(newElementValue, rawValue = null, saveChangeToHistory = true)

Source from the content-addressed store, hash-verified

2330 * @private
2331 */
2332 _setElementAndRawValue(newElementValue, rawValue = null, saveChangeToHistory = true) {
2333 if (AutoNumericHelper.isNull(rawValue)) {
2334 rawValue = newElementValue;
2335 } else if (AutoNumericHelper.isBoolean(rawValue)) {
2336 saveChangeToHistory = rawValue;
2337 rawValue = newElementValue;
2338 }
2339
2340 //XXX The order here is important ; the value should first be set on the element, then and only then we should update the raw value
2341 // In the `set()` function, we make sure to call `_setRawValue` *after* `setElementValue` so that if `_setRawValue` calls a callback that modify the `rawValue`, then the new value is set correctly (after `setElementValue` briefly set its value first)
2342 this._setElementValue(newElementValue);
2343 this._setRawValue(rawValue, saveChangeToHistory);
2344
2345 return this;
2346 }
2347
2348 /**
2349 * Return the multiplied raw value with the `rawValueDivisor`.

Callers 4

constructorMethod · 0.95
setMethod · 0.95
setValueMethod · 0.95

Calls 4

_setElementValueMethod · 0.95
_setRawValueMethod · 0.95
isNullMethod · 0.80
isBooleanMethod · 0.80

Tested by

no test coverage detected