@@ -4434,23 +4434,25 @@ function foldup(evt, opts) {
44344434 if (!("open" in opts)) {
44354435 opts.open = acting.ariaExpanded !== "true";
44364436 }
4437- const p = acting.closest(".expanded, .collapsed"),
4438- controls = acting.getAttribute("aria-controls");
4439- for (const e of p.querySelectorAll("button[aria-expanded]")) {
4440- if (e.getAttribute("aria-controls") === controls) {
4441- e.ariaExpanded = opts.open ? "true" : "false";
4442- }
4443- }
44444437 for (const e of acting.ariaControlsElements) {
44454438 if (e.hidden !== !opts.open && !hasClass(e, "no-fold")) {
44464439 e.hidden = !opts.open;
44474440 e.dispatchEvent(new CustomEvent("foldtoggle", {bubbles: true, detail: opts}));
44484441 }
44494442 }
4450- if (p && hasClass(p, "expanded") !== opts.open) {
4451- removeClass(p, opts.open ? "collapsed" : "expanded");
4452- addClass(p, opts.open ? "expanded" : "collapsed");
4453- p.dispatchEvent(new CustomEvent("foldtoggle", {bubbles: true, detail: opts}));
4443+ const p = acting.closest(".expanded, .collapsed");
4444+ if (p) {
4445+ const controls = acting.getAttribute("aria-controls");
4446+ for (const e of p.querySelectorAll("button[aria-expanded]")) {
4447+ if (e.getAttribute("aria-controls") === controls) {
4448+ e.ariaExpanded = opts.open ? "true" : "false";
4449+ }
4450+ }
4451+ if (hasClass(p, "expanded") !== opts.open) {
4452+ removeClass(p, opts.open ? "collapsed" : "expanded");
4453+ addClass(p, opts.open ? "expanded" : "collapsed");
4454+ p.dispatchEvent(new CustomEvent("foldtoggle", {bubbles: true, detail: opts}));
4455+ }
44544456 }
44554457 } else {
44564458 let target = this;
0 commit comments