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

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.

  • 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. – Lucas Ennouchi Jun 25 '19 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.

  • Thank you but this exactly the reason why I'm asking this question... What if it is a third party JS which uses document ? – Lucas Ennouchi Jun 25 '19 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. – AbdoulayeDIOP Jun 25 '19 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.