Skip to content

Commit

Permalink
[5.1] Fix JavaScript error caused by using "switcher" layout for radi…
Browse files Browse the repository at this point in the history
…o buttons in subforms (joomla#43804)
  • Loading branch information
mattelkins-bluefrontier authored and dgrammatiko committed Aug 11, 2024
1 parent 702367b commit c851737
Showing 1 changed file with 16 additions and 6 deletions.
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

0 comments on commit c851737

Please sign in to comment.