* Add the given object to the global AutoNumeric element list. * * @param {AutoNumeric} autoNumericObject * @private
(autoNumericObject)
| 3618 | * @private |
| 3619 | */ |
| 3620 | static _addToGlobalList(autoNumericObject) { |
| 3621 | if (!this._doesGlobalListExists()) { |
| 3622 | this._createGlobalList(); |
| 3623 | } |
| 3624 | |
| 3625 | const domElement = autoNumericObject.node(); |
| 3626 | // This checks if the object is not already in the global list before adding it. |
| 3627 | // This could happen if an AutoNumeric element is initialized, then the DOM element is removed directly via `removeChild` (hence the reference does not get removed from the global list), then it get recreated and initialized again |
| 3628 | if (this._isInGlobalList(domElement)) { |
| 3629 | if (this._getFromGlobalList(domElement) === this) { |
| 3630 | // Do not add this AutoNumeric object again since it's already in that global list |
| 3631 | return; |
| 3632 | } else { |
| 3633 | // Print a warning to warn that the domElement already has a reference in the global map (but we cannot for sure starts deleting those old references since they could still be used by another AutoNumeric object) |
| 3634 | AutoNumericHelper.warning(`A reference to the DOM element you just initialized already exists in the global AutoNumeric element list. Please make sure to not initialize the same DOM element multiple times.`, autoNumericObject.getSettings().showWarnings); |
| 3635 | } |
| 3636 | } |
| 3637 | |
| 3638 | window[this.autoNumericGlobalListName].set(domElement, autoNumericObject); |
| 3639 | } |
| 3640 | |
| 3641 | /** |
| 3642 | * Remove the given object from the global AutoNumeric element list. |
no test coverage detected