chore: remove duplicate code and throw generic error if nodes are not present

on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
darshanr0107
2025-08-08 13:52:22 +05:30
parent 688d9b383d
commit 28717e108d
2 changed files with 2 additions and 3 deletions

View File

@@ -43,7 +43,6 @@ export class MindmapDB {
this.nodeType = nodeType;
this.clear();
this.getType = this.getType.bind(this);
this.getMindmap = this.getMindmap.bind(this);
this.getElementById = this.getElementById.bind(this);
this.getParent = this.getParent.bind(this);
this.getMindmap = this.getMindmap.bind(this);

View File

@@ -65,8 +65,8 @@ export function validateLayoutData(data: LayoutData): boolean {
throw new Error('Root node is required');
}
if (!Array.isArray(data.nodes)) {
throw new Error('Nodes array is required in layout data');
if (!data.nodes || !Array.isArray(data.nodes) || data.nodes.length === 0) {
throw new Error('No nodes found in layout data');
}
if (!Array.isArray(data.edges)) {