Nic30 / d3-hwschematic

D3.js and ELK based schematic visualizer
Eclipse Public License 2.0
93 stars 13 forks source link

LPort hwMeta.cssClass is ignored unless hwMeta.cssStyle is also defined (generic port renderer only) #29

Closed dkilfoyle closed 8 months ago

dkilfoyle commented 9 months ago

Hi. I think the problem lies here (noderenders/generic.js):

renderPorts(node) {
    var schematic = this.schematic;
    var PORT_HEIGHT = schematic.PORT_HEIGHT;
    var CHAR_WIDTH = schematic.CHAR_WIDTH;
    var portG = node.selectAll(".port")
        .data(function(d) {
            return d.ports || [];
        })
        .enter()
        .append("g")
        .attr("style", (d) => d.hwMeta.cssStyle)
        .attr("class", (d) => {
            if (d.hwMeta.cssStyle) {                 // <<===== this should be d.hwMeta.cssClass?
                return "port " + d.hwMeta.cssClass;
            } else {
                return "port";
            }
        });

The mux and operator port renders work correctly with the above line set to if (d.hwMeta.cssClass).

I discovered this while trying to set cssClass for the port of an isExternalPort=true node.

Nic30 commented 8 months ago

Yes, it was swapped.