29
0
mirror of https://github.com/joomla/joomla-cms.git synced 2024-06-26 07:13:21 +00:00

Fix validator compatibility break (#40230)

This commit is contained in:
Fedir Zinchuk 2023-03-30 22:00:22 +03:00 committed by GitHub
parent e65d28486b
commit b285fa67e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -249,10 +249,15 @@ class JFormValidator {
let valid = true;
let message;
let error;
let fields;
const invalid = [];
// Validate form fields
const fields = [].slice.call(form.elements);
if (form.nodeName === 'FORM') {
fields = [].slice.call(form.elements);
} else {
fields = [].slice.call(form.querySelectorAll('input, textarea, select, button, fieldset'));
}
fields.forEach((field) => {
if (this.validate(field) === false) {
valid = false;
@ -284,7 +289,13 @@ class JFormValidator {
attachToForm(form) {
const inputFields = [];
const elements = [].slice.call(form.elements);
let elements;
if (form.nodeName === 'FORM') {
elements = [].slice.call(form.elements);
} else {
elements = [].slice.call(form.querySelectorAll('input, textarea, select, button, fieldset'));
}
// Iterate through the form object and attach the validate method to all input fields.
elements.forEach((element) => {