MCPcopy
hub / github.com/autoNumeric/autoNumeric / _setElementValue

Method _setElementValue

src/AutoNumeric.js:2294–2318  ·  view source on GitHub ↗

* Set the given value on the DOM element, without affecting the `rawValue`. * This sends an 'autoNumeric:formatted' event if the new value is different from the old one. * * @param {number|string} newElementValue * @param {boolean} [sendFormattedEvent=true] If set to `true`, then

(newElementValue, sendFormattedEvent = true)

Source from the content-addressed store, hash-verified

2292 * @private
2293 */
2294 _setElementValue(newElementValue, sendFormattedEvent = true) {
2295 //TODO Use an internal attribute to track the current value of the element `formattedValue` (like its counterpart `rawValue`). This would allow us to avoid calling `getElementValue` many times
2296 const oldElementValue = AutoNumericHelper.getElementValue(this.domElement);
2297
2298 // Only update the value if it's different from the current one
2299 if (newElementValue !== oldElementValue) {
2300 this.internalModification = true;
2301 AutoNumericHelper.setElementValue(this.domElement, newElementValue);
2302 this.internalModification = false;
2303
2304 if (sendFormattedEvent) {
2305 this._triggerEvent(AutoNumeric.events.formatted, this.domElement, {
2306 oldValue : oldElementValue,
2307 newValue : newElementValue,
2308 oldRawValue: this.rawValue,
2309 newRawValue: this.rawValue,
2310 isPristine : this.isPristine(false),
2311 error : null,
2312 aNElement : this,
2313 });
2314 }
2315 }
2316
2317 return this;
2318 }
2319
2320 /**
2321 * Set the given value on the DOM element, and the raw value on `this.rawValue`, if both are given.

Callers 10

unformatMethod · 0.95
unformatLocalizedMethod · 0.95
wipeMethod · 0.95
_unformatOnSubmitMethod · 0.95
_setValuePartsMethod · 0.95
_formatValueMethod · 0.95

Calls 4

_triggerEventMethod · 0.95
isPristineMethod · 0.95
getElementValueMethod · 0.80
setElementValueMethod · 0.80

Tested by

no test coverage detected