MCPcopy
hub / github.com/autoNumeric/autoNumeric / form

Method form

src/AutoNumeric.js:3099–3124  ·  view source on GitHub ↗

* Return a reference to the parent element if it exists, otherwise return `null`. * If the parent form element as already been found, this directly return a reference to it. * However, you can force AutoNumeric to search again for its reference by passing `true` as a parameter to th

(forceSearch = false)

Source from the content-addressed store, hash-verified

3097 * @returns {HTMLFormElement|null}
3098 */
3099 form(forceSearch = false) {
3100 if (forceSearch || AutoNumericHelper.isUndefinedOrNullOrEmpty(this.parentForm)) {
3101 const newParentForm = this._getParentForm();
3102 if (!AutoNumericHelper.isNull(newParentForm) && newParentForm !== this.parentForm) {
3103 // If the current parent form exists and is different from the previous parent form
3104
3105 // Search for all the AutoNumeric elements in the old parent form
3106 const oldANChildren = this._getFormAutoNumericChildren(this.parentForm);
3107 // Update the anCount with the correct number of AutoNumeric elements
3108 this.parentForm.dataset.anCount = oldANChildren.length;
3109
3110 // Check if the new parent form already has a anFormHandler name
3111 if (this._hasFormHandlerFunction(newParentForm)) {
3112 this._incrementParentFormCounter(newParentForm); // Increment its counter
3113 } else {
3114 // Create one and set the anCount to 1
3115 this._storeFormHandlerFunction(newParentForm);
3116 this._initializeFormCounterToOne(newParentForm);
3117 }
3118 }
3119
3120 this.parentForm = newParentForm;
3121 }
3122
3123 return this.parentForm;
3124 }
3125
3126 /**
3127 * Returns an array of the AutoNumeric-managed elements for the given form element is passed, otherwise for the current `this.parentForm` element.

Callers 13

formNumericStringMethod · 0.95
formFormattedMethod · 0.95
formLocalizedMethod · 0.95
formArrayFormattedMethod · 0.95
formArrayLocalizedMethod · 0.95
formUnformatMethod · 0.95
formUnformatLocalizedMethod · 0.95
formReformatMethod · 0.95
formSubmitFormattedMethod · 0.95
formSubmitLocalizedMethod · 0.95

Calls 8

_getParentFormMethod · 0.95
isNullMethod · 0.80

Tested by

no test coverage detected