mootools / mootools-core

MooTools Core Repository
https://mootools.net
2.65k stars 505 forks source link

MooTools in compatibility mode conflicts with React.js #2773

Closed dmitrizzle closed 7 years ago

dmitrizzle commented 7 years ago

Tested with MooTools 1.5.2 and 1.6.0 in compat mode. Both times I get error (see screenshot) which caused click events coded in React to seise firing after the first time.

However, when I use MT without the compat mode the issue disappears. Also note that using MT without the compat mode with Angular produces another fatal error in browser console $clear is not defined.

screen shot 2016-09-29 at 7 34 59 pm

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/38468523-mootools-in-compatibility-mode-conflicts-with-react-js?utm_campaign=plugin&utm_content=tracker%2F22067&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F22067&utm_medium=issues&utm_source=github).
dizel3d commented 7 years ago

Seems, the reason is that in compatibility mode MooTools replaces Function.prototype.bind (that used by React) with non-standard implementation. #2511 I guess it won't be fixed.

timwienk commented 7 years ago

Indeed. Many problems like these are caused by using MooTools Core with compatibility additions while it is not necessary. You have to choose between compatibility with old MooTools or compliance with newer standards.

Since this issue is rather old, I assume it has been solved by now, but just to be clear:

Do not use MooTools libraries in compatibility mode when you do not need compatibility with old MooTools versions. Doing so is basically depriving yourself of newer JavaScript features.

whizsid commented 5 years ago

I have fixed this issue by deleting the line delete Function.prototype.bind;

RaymondBenc commented 4 years ago

@whizsid you're my hero. Thank you!