Diagram.rebuildParts() prints a lot of "Change not within a transaction" messages

The font on our app occasionally loads after GoJS draws the diagram. To combat this, I did the following:

$(document).on("TypeKitReady", function() {
    // myDiagram.startTransaction("refresh_font");
    myDiagram.rebuildParts();
    // myDiagram.commitTransaction("refresh_font");
});

With the code above, the entire diagram is redrawn with the right font. However, it prints a lot of “Change not within a transaction…” messages in the console.

When I wrap the call to rebuildParts() in a transaction, nothing happens (the old font remains in the diagram because the diagram didn’t actually re-draw itself).

Is this a bug?

That’s surprising. I’m unable to do anything with TypeKit and fonts, but when doing somethking similar involving loading images for Pictures, executing the rebuildParts within a transaction continued to re-create all of the nodes and links.

Is there a way that you can make a test app available to us?

I’ll check with my team on that bit and get back to you.

More surprising is that when rebuildParts is called on a palette, it does nothing. Wrapping it around a transaction doesn’t help either.

Is it not supposed to work for Palette?

Diagram.rebuildParts definitely removes all nodes and links that are modeled and then re-creates all of the nodes and links from the model data and performs any layout again.

I have noticed that for a Palette, it works sometimes, and doesn’t work at times. Any pointers on how to debug this?

I can’t think of a way to easily detect when something does not happen.

You can confirm that the Nodes and Links are different objects by checking their __gohashid values before and after.

Yes, the __gohashid changes after the call to rebuildParts().

OK, so you know that the Nodes and Links really were discarded and then rebuilt from model data.

That implies that there is still some font-related state that hasn’t been recognized by the browser. Perhaps the "TypeKitReady" event is too soon?

That doesn’t seem to be the case - the entire content on my app changes, other than that of the diagram. I even delayed that event by 1 second after it’s actually called using setTimeout.

I’m going to take over this issue via email.