Aha! Canvas Support to the rescue. At first they thought it was the depreciated JQuery that was the source of my JavaScript woes. After clarifying that we were not using the JQuery library anymore, they were able to do some more digging and find that there was a change in JavaScript loading sequences. Some other developers have discovered this as well: How to adapt to the undocumented JavaScript loading sequence changes?
One of the undocumented 6-22 changes was with the order of what loads on the page. JavaScript used to load last, now it loads first. Our accordion code looks for elements with the class "accordion" on the page, so if JS loads before the HTML classes are there, there are no elements to get. With that knowledge, I changed my code to wait for the page to load before running:
window.onload = function() {
let accordion = document.getElementsByClassName("accordion");
let i;
for (i = 0; i < accordion.length; i++) {
accordion[i].addEventListener("click", function() {
this.classList.toggle("active");
let panel = this.nextElementSibling;
if (panel.style.maxHeight){
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
}
});
}
}
I understand that this fix means the script will not run until the whole page has loaded (after every other script has finished and every image renders). So there is a potential that our accordions will not work while a large image completes rendering, but this will be a good quick fix until we figure out a good setInterval() solution.
No JQuery necessary!
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.