Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.1] Fix JavaScript error caused by using "switcher" layout for radio buttons in subforms #43804

Merged
merged 8 commits into from
Aug 10, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,12 @@ class JoomlaFieldSubform extends HTMLElement {
// Set the id for fieldset and group label
if (!countMulti) {
// Look for <fieldset class="checkboxes"></fieldset> or <fieldset><div class="checkboxes"></div></fieldset>
let fieldset = $el.closest('.checkboxes');
let fieldset = $el.closest('.checkboxes, fieldset');
// eslint-disable-next-line no-nested-ternary
fieldset = fieldset.nodeName === 'FIELDSET' ? fieldset : (fieldset.parentElement.nodeName === 'FIELDSET' ? fieldset.parentElement : false);
if (fieldset) {
// eslint-disable-next-line no-nested-ternary
fieldset = fieldset.nodeName === 'FIELDSET' ? fieldset : (fieldset.parentElement.nodeName === 'FIELDSET' ? fieldset.parentElement : false);
}

if (fieldset) {
const oldSetId = fieldset.id;
Expand All @@ -313,10 +316,17 @@ class JoomlaFieldSubform extends HTMLElement {

// Set the id for fieldset and group label
if (!countMulti) {
// Look for <fieldset class="radio"></fieldset> or <fieldset><div class="radio"></div></fieldset>
let fieldset = $el.closest('.radio');
// eslint-disable-next-line no-nested-ternary
fieldset = fieldset.nodeName === 'FIELDSET' ? fieldset : (fieldset.parentElement.nodeName === 'FIELDSET' ? fieldset.parentElement : false);
/**
* Look for one of:
* - <fieldset class="radio"></fieldset>
* - <fieldset><div class="radio"></div></fieldset>
* - <fieldset><div class="switcher"></div></fieldset>
*/
let fieldset = $el.closest('.radio, .switcher, fieldset');
if (fieldset) {
// eslint-disable-next-line no-nested-ternary
fieldset = fieldset.nodeName === 'FIELDSET' ? fieldset : (fieldset.parentElement.nodeName === 'FIELDSET' ? fieldset.parentElement : false);
}

if (fieldset) {
const oldSetId = fieldset.id;
Expand Down