Skip to content

Commit

Permalink
Fix validator compatibility break (#40230)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedik authored Mar 30, 2023
1 parent e65d284 commit b285fa6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions build/media_source/system/js/fields/validate.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit b285fa6

Please sign in to comment.