* Remove the watcher on the AutoNumeric-managed element * Note: This needs to be called when the AutoNumeric element is 'removed', otherwise the getter/setter stays on the DOM element and that can lead to problem if the user initialize another AutoNumeric object on it. * @private
()
| 1587 | * @private |
| 1588 | */ |
| 1589 | _removeWatcher() { |
| 1590 | // `getterSetter` can be undefined when a non-input element is used |
| 1591 | if (!AutoNumericHelper.isUndefined(this.getterSetter)) { |
| 1592 | const { set: setter, get: getter } = this.getterSetter; |
| 1593 | Object.defineProperty(this.domElement, this.attributeToWatch, { |
| 1594 | configurable: true, // This is needed in some rare cases |
| 1595 | get : () => getter.call(this.domElement), |
| 1596 | set : val => { |
| 1597 | setter.call(this.domElement, val); |
| 1598 | }, |
| 1599 | }); |
| 1600 | } |
| 1601 | |
| 1602 | //FIXME The code above fails for the `textContent` attribute since `this.getterSetter` is undefined when using `getOwnPropertyDescriptor()` |
| 1603 | /* //XXX The code below *almost* work for the textContent, but breaks some unit tests |
| 1604 | this.valueWatched = this.domElement[this.attributeToWatch]; |
| 1605 | Object.defineProperty(this.domElement, this.attributeToWatch, { |
| 1606 | configurable: true, // This is needed in some rare cases |
| 1607 | get : () => this.valueWatched, |
| 1608 | set : val => { |
| 1609 | this.valueWatched = val; |
| 1610 | }, |
| 1611 | }); |
| 1612 | */ |
| 1613 | } |
| 1614 | |
| 1615 | /** |
| 1616 | * Return the name of the object attribute that store the current formatted data in the DOM element. |