Skip to content

Commit dbe6041

Browse files
committed
safe guard for nested hetero-lists
1 parent 818563b commit dbe6041

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/main/js/components/dropdowns/hetero-list.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ function generateButtons() {
8181
}
8282

8383
convertInputsToButtons(c);
84+
const enableTopButton = c.getAttribute("enableTopButton") === "true";
8485
let btn = Array.from(c.querySelectorAll("BUTTON.hetero-list-add")).pop();
85-
let topButton = Array.from(
86-
c.querySelectorAll("BUTTON.hetero-list-add-top"),
87-
).shift();
86+
let topButton = enableTopButton
87+
? Array.from(c.querySelectorAll("BUTTON.hetero-list-add-top")).shift()
88+
: null;
8889

8990
let prototypes = c.lastElementChild;
9091
while (!prototypes.classList.contains("prototypes")) {
@@ -183,7 +184,7 @@ function generateButtons() {
183184
if (
184185
addOnTop &&
185186
!honorOrder &&
186-
c.getAttribute("enableTopButton") === "true"
187+
enableTopButton
187188
) {
188189
let children = Array.from(c.children).filter(function (n) {
189190
return n.classList.contains("repeated-chunk");

0 commit comments

Comments
 (0)