magjac / d3-graphviz

Graphviz DOT rendering and animated transitions using D3
BSD 3-Clause "New" or "Revised" License
1.67k stars 103 forks source link

Error when rendering an initial graph with an edge from a node with a name equal to a property of the JavaScript Object type and growEnteringEdges is enabled #301

Closed magjac closed 5 months ago

magjac commented 5 months ago

Initial rendering (i.e., not transitioning into) a graph e.g. like this:

digraph {constructor -> b}

when the growEnteringEdges option is enabled (default), generates an error like this:

Uncaught TypeError: prevStartNode.children is undefined
    extractGrowingEdgesData dot.js:280
    postProcessDataPass2Global dot.js:319
    postProcessDataPass2Global dot.js:321
    postProcessDataPass2Global dot.js:320
    postProcessDataPass2Global dot.js:321
    postProcessDataPass2Global dot.js:320
    postProcessDataPass2Global dot.js:321
    postProcessDataPass2Global dot.js:320
    layoutDone dot.js:345
    dot dot.js:118
    layout dot.js:77
    onmessage dot.js:41
    initViz dot.js:39
    Graphviz graphviz.js:159
    selection_graphviz graphviz.js:14
    <anonymous> basic.html:10
[dot.js:280:32](http://0.0.0.0:8000/src/dot.js)
    extractGrowingEdgesData dot.js:280
    postProcessDataPass2Global dot.js:319
    postProcessDataPass2Global dot.js:321
    forEach self-hosted:203
    postProcessDataPass2Global dot.js:320
    postProcessDataPass2Global dot.js:321
    forEach self-hosted:203
    postProcessDataPass2Global dot.js:320
    postProcessDataPass2Global dot.js:321
    forEach self-hosted:203
    postProcessDataPass2Global dot.js:320
    layoutDone dot.js:345
    dot dot.js:118
    layout dot.js:77
    onmessage dot.js:41
    (Async: EventHandlerNonNull)
    initViz dot.js:39
    Graphviz graphviz.js:159
    selection_graphviz graphviz.js:14
    <anonymous> basic.html:10

Any of these node names will give the same problem:

    constructor
    __defineGetter__
    __defineSetter__
    hasOwnProperty
    __lookupGetter__
    __lookupSetter__
    isPrototypeOf
    propertyIsEnumerable
    toString
    valueOf
    __proto__
    toLocaleString