Skip to content

Commit 701503d

Browse files
committed
Only add key if missing
1 parent 64bb2b0 commit 701503d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ export function applyDefaults(options : SortableOptions, root : VNode) : Sortabl
3434
export function addKeys(node : VNode, key : string = Math.random().toString()) : VNode
3535
{
3636
if (!node.children) {
37-
return { ...node, key };
37+
return { ...node, key: node.key ? node.key : key };
3838
}
3939

4040
const children : VNode[] = (node.children as VNode[]).map((c, i) => addKeys(c, key + '-' + i));
4141

42-
return { ...node, key, children };
42+
return { ...node, key: node.key ? node.key : key, children };
4343
}
4444

4545
/**

0 commit comments

Comments
 (0)