diff --git a/js/accordion.frontend.js b/js/accordion.frontend.js --- a/js/accordion.frontend.js +++ b/js/accordion.frontend.js @@ -141,10 +141,13 @@ for (let i = 0; i < $ckeditorAccordions.length; i++) { // The first one is the correct one. if (!drupalSettings.ckeditorAccordion.accordionStyle.collapseAll) { - $accordion.querySelector('dt:first-child').classList.add('active'); - let dd = $accordion.querySelector('dd:first-of-type'); - dd.classList.add('active'); - dd.style.display = 'block'; + const firstDt = $accordion.querySelector('dt:first-child'); + const firstDd = $accordion.querySelector('dd:first-of-type'); + if (firstDt && firstDd) { + firstDt.classList.add('active'); + firstDd.classList.add('active'); + firstDd.style.display = 'block'; + } } // Turn the accordion tabs to links so that the content is accessible & can be traversed using keyboard. diff --git a/js/accordion.frontend.min.js b/js/accordion.frontend.min.js --- a/js/accordion.frontend.min.js +++ b/js/accordion.frontend.min.js @@ -1 +1 @@ -!function(e,v,m){"use strict";let f=!1,k=[];const w={duration:300,easing:(e,t,i,o)=>(e/=o/2)<1?i/2*e*e+t:-i/2*(--e*(e-2)-1)+t},L={OPEN:1,CLOSE:2},A=(t,i)=>{let o=!1;for(let e=0;eA(t,e));else{for(let e=0;e'+d+""}c.classList.add("styled"),c.classList.remove("ckeditor-accordion");var g=document.createElement("div"),p=(g.classList.add("ckeditor-accordion-container"),o||g.classList.add("no-animations"),c.after(g),g.appendChild(c),new Event("ckeditorAccordionAttached")),y=(c.dispatchEvent(p),c.querySelectorAll(".ckeditor-accordion-toggler"));for(let e=0;e{var t=e[1],i=Object.assign({},w);"slideUp"==e[0]?(i.direction=L.CLOSE,i.to=0,i.startingHeight=t.scrollHeight,i.distanceHeight=-i.startingHeight,t.style.display="block",t.style.overflow="hidden",t.style.marginTop="0",t.style.marginBottom="0",t.style.paddingTop="0",t.style.paddingBottom="0"):(t.style.height="0px",t.style.display="block",t.style.overflow="hidden",t.style.marginTop="0",t.style.marginBottom="0",t.style.paddingTop="0",t.style.paddingBottom="0",i.direction=L.OPEN,i.to=t.scrollHeight,i.startingHeight=0,i.distanceHeight=i.to),delete i.startTime,o.push([t,i])}),window.requestAnimationFrame(e=>A(o,e))}else n.forEach(e=>{var t=e[1];"slideUp"==e[0]?t.style.display="none":t.style.display="block"}),f=!1;e.preventDefault()});if(n){var u=document.querySelectorAll('a[href*="#"]:not(.ckeditor-accordion-toggler):not(.visually-hidden)');for(let e=0;e(e/=o/2)<1?i/2*e*e+t:-i/2*(--e*(e-2)-1)+t},L={OPEN:1,CLOSE:2},A=(t,i)=>{let o=!1;for(let e=0;eA(t,e));else{for(let e=0;e'+d+""}c.classList.add("styled"),c.classList.remove("ckeditor-accordion");var g=document.createElement("div"),p=(g.classList.add("ckeditor-accordion-container"),o||g.classList.add("no-animations"),c.after(g),g.appendChild(c),new Event("ckeditorAccordionAttached")),y=(c.dispatchEvent(p),c.querySelectorAll(".ckeditor-accordion-toggler"));for(let e=0;e{var t=e[1],i=Object.assign({},w);"slideUp"==e[0]?(i.direction=L.CLOSE,i.to=0,i.startingHeight=t.scrollHeight,i.distanceHeight=-i.startingHeight,t.style.display="block",t.style.overflow="hidden",t.style.marginTop="0",t.style.marginBottom="0",t.style.paddingTop="0",t.style.paddingBottom="0"):(t.style.height="0px",t.style.display="block",t.style.overflow="hidden",t.style.marginTop="0",t.style.marginBottom="0",t.style.paddingTop="0",t.style.paddingBottom="0",i.direction=L.OPEN,i.to=t.scrollHeight,i.startingHeight=0,i.distanceHeight=i.to),delete i.startTime,o.push([t,i])}),window.requestAnimationFrame(e=>A(o,e))}else n.forEach(e=>{var t=e[1];"slideUp"==e[0]?t.style.display="none":t.style.display="block"}),f=!1;e.preventDefault()});if(n){var u=document.querySelectorAll('a[href*="#"]:not(.ckeditor-accordion-toggler):not(.visually-hidden)');for(let e=0;e