UNPKG

@nent/core

Version:

Functional elements to add routing, data-binding, dynamic HTML, declarative actions, audio, video, and so much more. Supercharge static HTML files into web apps without script or builds.

30 lines (28 loc) 978 B
/*! * NENT 2022 */ /** * It checks if the input elements are valid or not. * @param {HTMLElement} rootElement - HTMLElement - The root element to search for inputs. * @returns A boolean value. */ function getChildInputValidity(rootElement) { const inputElements = [ ...Array.from(rootElement.querySelectorAll('input')), ...Array.from(rootElement.querySelectorAll('textarea')), ...Array.from(rootElement.querySelectorAll('select')), ...Array.from(rootElement.querySelectorAll('*[n-validate]')), ]; const results = inputElements.map((i) => { var _a, _b; if (((_a = i.checkValidity) === null || _a === void 0 ? void 0 : _a.call(i)) === false || ((_b = i.reportValidity) === null || _b === void 0 ? void 0 : _b.call(i)) === false) { return false; } return true; }); if (rootElement.querySelectorAll('*[invalid]').length) return false; return !results.some(v => v == false); } export { getChildInputValidity as g };