Skip to content

Commit

Permalink
fixed subnodes with undefined parent
Browse files Browse the repository at this point in the history
  • Loading branch information
nglgzz committed Jul 15, 2017
1 parent 1b5aa66 commit 8116b00
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/utils/d3.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ export const d3Connections = (svg, connections) => (
export const d3Nodes = (svg, nodes) => (
bindData(svg, nodes, 'foreignObject')
.attr('class', 'mindmap-node')
.attr('id', node => node.text.replace(/^[ ./~\-:+#]*\d*|[ ./~\-:+#]/g, ''))
.attr('id', (node) => {
if (!node.text) {
return 'undefined';
}

return node.text.replace(/^[ ./~\-:+#]*\d*|[ ./~\-:+#]/g, '')
})
.attr('width', node => node.width + 4)
.attr('height', node => node.height)
.html(node => node.html)
Expand All @@ -44,7 +50,7 @@ export const d3Subnodes = (svg, subnodes) => {
const nestedSubs = nest()
.key((sub) => {
if (!sub.parent) {
return undefined;
return 'undefined';
}

return sub.parent.replace(/^[ ./~\-:+#]*\d*|[ ./~\-:+#]/g, '');
Expand Down

0 comments on commit 8116b00

Please sign in to comment.