* Returns a reference to the parent element if it exists, otherwise return `null`. * * @returns {HTMLFormElement|null} * @private
()
| 3169 | * @private |
| 3170 | */ |
| 3171 | _getParentForm() { |
| 3172 | if (!AutoNumericHelper.isUndefined(this.domElement.form)) return this.domElement.form; // This catches input elements outside the form element |
| 3173 | |
| 3174 | if (this.domElement.tagName.toLowerCase() === 'body') { |
| 3175 | return null; |
| 3176 | } |
| 3177 | |
| 3178 | let node = this.domElement; |
| 3179 | let tagName; |
| 3180 | do { |
| 3181 | node = node.parentNode; |
| 3182 | if (AutoNumericHelper.isNull(node)) { |
| 3183 | // Special case when using templates with frameworks like Vue.js, where the input element can be 'detached' when initializing the DOM structure |
| 3184 | return null; |
| 3185 | } |
| 3186 | |
| 3187 | if (node.tagName) { |
| 3188 | tagName = node.tagName.toLowerCase(); |
| 3189 | } else { |
| 3190 | tagName = ''; |
| 3191 | } |
| 3192 | |
| 3193 | if (tagName === 'body') { |
| 3194 | // Get out of the loop if we get up to the `<body>` element |
| 3195 | break; |
| 3196 | } |
| 3197 | } while (tagName !== 'form'); |
| 3198 | |
| 3199 | if (tagName === 'form') { |
| 3200 | return node; |
| 3201 | } else { |
| 3202 | return null; |
| 3203 | } |
| 3204 | } |
| 3205 | |
| 3206 | /** |
| 3207 | * Return a string in standard URL-encoded notation with the form input values being unformatted. |
no test coverage detected