mootools / mootools-core

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

instanceOf: infinite loop #2780

Open olgierd23 opened 7 years ago

olgierd23 commented 7 years ago

In some (rare) cases function instanceOf may fall into an infinite loop, which - in my case - was possible to eliminate by adding additional conditional break.

while (constructor){
    if (constructor === object) return true;
    if (constructor === constructor.parent) break;       // this line should be added
    constructor = constructor.parent;
}
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/41965165-instanceof-infinite-loop?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).
SergioCrisostomo commented 7 years ago

@olgierd23 could you provide a jsFiddle reproducing this?

olgierd23 commented 7 years ago

Unfortunately, I am afraid I could not. It have happened in my system (which is quite big and complicated) some time ago, and I found this issue during debbuging. I fixed it in the above mentiond way and did not make any notes concerning the situation. So now I only know that there was the issue, but can not recover that situation again. :-(

DimitarChristoff commented 7 years ago

I am not sure how this matters, you wouldn't cause recursion unless your class somehow extends itself...

https://jsfiddle.net/f7qr6zfh/1/

this checks all subclassing examples under mootools and ES6 classes and works correctly.

stefanklokgieters commented 7 years ago

How actively it MooTools still being maintained/ developed?

SergioCrisostomo commented 7 years ago

@stefanklokgieters since ES6 landed, much of what MooTools brought to JavaScript is now Native. Afaik MooTools 1.6.x is stable. If we find important bugs we should fix them. By "we" I mean devs and community :)

Discussing this is off-topic here, we had a thread in the Google mailinglist about this. Feel free to contact me, check the Gitter channel, #IRC or write in the mailing list if you have more questions.