iitc-project / ingress-intel-total-conversion

ingress.com/intel total conversion user script with some new features. Should allow easier extension of the intel map.
http://iitc.jonatkins.com/
ISC License
989 stars 552 forks source link

Renamed LeafLet 'L' to '_L'. #1164

Closed McBen closed 7 years ago

McBen commented 7 years ago

(prepared) fix for #964 "TypeError: L is not a constructor"

For 3rd-party plugins there is still a workaround ("L = _L" in boot.js) to give 3rd-party developer time to adjust their code. You have to remove this workaround to fix the #964.

As preparation developers should add something like: "var _L = window._L || L; // TODO: remove on iitc update"

Note 1: no 'external' files were changed Note 2: a bunch of plugins are affected. I wasn't able to fully-test them all.

McBen commented 7 years ago

to be more precisely what is done in this PR:

nhamer commented 7 years ago

This is really only cosmetic in the debugger, and the temporary "window.L = window._L;" is all-but-permanent.

McBen commented 7 years ago

I would keep the window.L = window._L just for one release.

Yeah, ATM it's just a cosmetic fix (but is reported again and again). Things may change when the Nia-Minifier choose another function L (worst case).

dingram commented 7 years ago

Thank you for the pull request. Unfortunately, it's very much not feasible to do this, particularly over the lifespan of a single release. There are a lot of plugins out there which use Leaflet, and I'm sure several of them are no longer actively maintained.

Breaking compatibility in such a major way simply for a cosmetic fix is not something I am prepared to accept. I discuss some of the possibilities in #964, including this particular solution.

In short, it is possible to remove this warning, and there are two possible fixes that I consider reasonable:

  1. If the click listener which causes this message is set on the <body> element, the fix is to completely replace the <head> and <body> elements, rather than their contents. This would remove any registered event listeners and side-step the problem
  2. If the listener which causes this message is set on the document, however, then we need to do some GreaseMonkey/TamperMonkey magic in order to catch the event listeners before they are added by stock Intel, so we can remove them later once IITC initializes.
McBen commented 7 years ago

just some notes: a) stock-intels 'L' is choosen by a minifier and may change with every release. b) ATM 'L' is a (base-?) class and not related to any click-event.