2

I'm trying to use mxgraph JS with editors. Within mxClient.js (main source for mxgraph) there are calls to document.getElementBy...(...) to retrieve containers for toolbars, graph etc.

As mentioned LWC developer guide :

Don’t use the window or document global properties to query for DOM elements.

So, mxGraph is failing...

I was wondering how to deal with this without updating the myClient.js file with references to this.template.querySelector(...)

Thanks

2 Answers 2

3

If you do not wish to modify the library's code (and that's a perfectly valid choice), you'll have to iframe the graph. However, that may be a pain due to viewport sizing and scrolling.

1
  • Thanks! You confirmed my fears :) I think I will go with editing the library as it may be painful now but indeed much flexible later than to work with iframes. Commented Jun 25, 2019 at 12:25
0

IMPORTANT Don’t use the window or document global properties to query for DOM elements. use this.template.querySelector('yourSelector') it's better.

2
  • Thank you but this exactly the reason why I'm asking this question... What if it is a third party JS which uses document ? Commented Jun 25, 2019 at 11:56
  • honestly i do not know but i think you should try to see if the third party is compatible with lwc. If so, you should not worry about it. Commented Jun 25, 2019 at 12:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .