I face the same issue. In my case, I use
IFrames to display diagrams, so document reference, which GoJS uses is not correct, I give a
HTMLDivElement to the constructor, like the author of this topic did, but GoJS raises the same error, even though diagram works perfectly fine in a local-window.
The problem ultimately lays with a check for
node instanceof HTMLDivElement in the GoJS source code, in the
go.GraphObject.make and few other functions (I found at least 3 of these checks in the newest version). The library is not aware in which context it is being used and what DOM node is given to it.
As described in this stackoverflow answer https://stackoverflow.com/a/5724974 and also in https://stackoverflow.com/a/42950193 answer comments,
instanceof might give unexpected result if it is called from a different scope. In my case I initialize
go.Diagram from a main window, but the DOM, in which diagram is created - in an
IFrame. So at the end
node instanceof HTMLDivElement just always gives
false and because of it, then the function tries to read parameter as an
object, which then leads to trying to read align attribute on the
HTMLDivElement node https://developer.mozilla.org/en-US/docs/Web/API/HTMLDivElement and assigning it to the
instanceof giving false assumptions, I would suggest to change this check to an alternative, which would not be influenced by the
window context being something else than expected.
There are at least 3 different alternatives:
div instanceof HTMLDivElement
1. div.toString() === '[object HTMLDivElement]'
2. div.tagName === "DIV"
3. div.nodeName === "DIV"
I’ve in a hacky way replaced
instanceof comparison in GoJs source with the first alternative, to check if that would solve the issue, and it did, no errors were raised from GoJS library. Everything was working as expected. Obviously, I wouldn’t like to do hacking (because of obvious reasons) and I would like, that GoJS support this kind of scenario. The recommended way I guess would be to use
tagName. Would this be possible to change?
I’m attaching a fiddle in which error can be seen (open up dev tools console): https://jsfiddle.net/Lbroqyud/