Skip to content

Commit a5cf408

Browse files
render on null list
1 parent 23fc97a commit a5cf408

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/core/renderHelper.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,22 @@ function getSlot(slots, key) {
88
}
99

1010
function computeNodes({ $slots, realList, getKey }) {
11+
const normalizedList = realList || [];
1112
const [header, footer] = ["header", "footer"].map(name =>
1213
getSlot($slots, name)
1314
);
1415
const { item } = $slots;
1516
if (!item) {
1617
throw new Error("draggable element must have an item slot");
1718
}
18-
const defaultNodes = realList.flatMap((element, index) =>
19+
const defaultNodes = normalizedList.flatMap((element, index) =>
1920
item({ element, index }).map(node => {
2021
node.key = getKey(element);
2122
node.props = { ...(node.props || {}), "data-draggable": true };
2223
return node;
2324
})
2425
);
25-
if (defaultNodes.length !== realList.length) {
26+
if (defaultNodes.length !== normalizedList.length) {
2627
throw new Error("Item slot must have only one child");
2728
}
2829
return {

0 commit comments

Comments
 (0)