georgemandis / konami-js

Adding the Konami Code easter egg to your projects since 2009! Compatible with gestures on smartphones and tablets as well. Compatible with all front-end frameworks and vanilla JavaScript
http://konamijs.mand.is/
MIT License
961 stars 121 forks source link

Usage of "const" keyword breaks older browsers and uglifyjs2 #35

Closed karl-sjogren closed 7 years ago

karl-sjogren commented 7 years ago

In the last update you are using the "const" keyword in a single place.

https://github.com/snaptortoise/konami-js/blob/060339e39599c0fb9f87dcaa1bc22102ec4ed3df/konami.js#L77

This breaks in older IE (< 11) and some mobile browser. It also breaks running your code through uglifyjs2 unless I run it through babel first. How about switching it back to a regular "var" instead to make life easier for everyone? :)

Edit

You are also using the shorthand form for declaring a method in one place it seems.

https://github.com/snaptortoise/konami-js/blob/060339e39599c0fb9f87dcaa1bc22102ec4ed3df/konami.js#L102

I'm not sure about browser support here but it breaks uglifyjs2 at least.

georgemandis commented 7 years ago

You're right. I do want to maintain backwards compatibility. I'm considering branching this project and making a more modern ES6-friendly version on Konami-JS at some point.

I'll merge the pull request.

karl-sjogren commented 7 years ago

Thanks!

Also, you could rewrite it using ES6 right now if you add a Babel workflow to transpile a version of it down to ES5 as well. That way people get to chose which version they want without the need to maintain two different branches of the project.

georgemandis commented 7 years ago

That's a great idea @karl-sjogren. I'll look to do that when I can. In the meantime I've made the fix you suggested here.