CodeMirror is playing on Primitive's prototype... Can we avoid it?

Hello everyone,

Today I stumbled on a nasty bug completely unrelated to CodeMirror… The library (FileAPI) was completely crashing when it tried to grab the ‘name’ property of some objects. The problem in this part of code is that it can also receive strings, but they were getting treated as objects because of the name method introduced in the String prototype by CodeMirror.

The most basic javascript rule is to create separate functionalities into modules so they don’t clash against each others. Both CodeMirror and FileAPI are loading in the correct fashion but there is still (of course) a clash because of prototype modifications of the most basic javascript objects.

Even though I certainly could understand the motivation behind this, I doubt it is an absolute need. Are there any plans on refactoring the library so it does not rely on those prototypes?

Could you point at the code that’s doing this? Because I am not aware of CodeMirror doing any such thing.

Hello Marijn,

Thanks for your quick reply. Actually, I’ve been a bit too fast on conclusion. It is not CodeMirror itself, it is JSHINT which is used by CodeMirror that does it.

Actually, JSHINT is not even using prototypes anymore, I was using an old version.

Sorry for jumping to conclusions too fast.

Great, thanks for getting back on that.