jssor / slider

Touch swipe image slider/slideshow/gallery/carousel/banner mobile responsive bootstrap

Home Page:https://www.jssor.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

You need to remove the event.keyCode because it's Deprecated

opened this issue · comments

Hi,

You use event.keyCode four times and you should replace it with the event.key instead.

Deprecated: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode

Change to this: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key

When I look at the source code on cdnjs latest version: https://cdnjs.cloudflare.com/ajax/libs/jssor-slider/27.5.0/jssor.slider.min.js

I see the following code:

a.keyCode==37
a.keyCode==39

Also you should be using strict.

Can you change them to the following:

a.key === 'ArrowLeft'
a.key === 'ArrowRight'

Also why are you using slider/js/jquery-1.9.1.min.js

That version has many XSS attacks, please update to latest version!

commented

@ayumihamsaki Great job, many thanks!

It's time to update event.keyCode with event.key, and the jquery version.
We will implement this in the coming version 28.0.0.

For "use strict", it's not necessary. It's not recommended to use “use strict” in ES6, ES6 modules are always in strict mode by default.

https://stackoverflow.com/questions/31685262/not-recommended-to-use-use-strict-in-es6

@jssor

I'm not talking about "use strict"; I am talking about === instead of ==.

Let me know if you need any changes to the attached pr, or you will merge it.

commented

Don't you think == work?

No you should not be doing that. It's 2019 there is no reason why you should not be using strict logical operators, that's just bad coding practises.

See here for the reason: https://stackoverflow.com/questions/359494/which-equals-operator-vs-should-be-used-in-javascript-comparisons

commented

I see.

Be aware that both === and "use strict" help for coding. It prevents unrestricted code, it reduces mistakes in your code. So, it's good behavior, please keep on. But if there is no mistake in your code, nothing matters.

=== is recommended good practice coding style.
== is also good practice coding style if you think so, it's up to you.

Again, thanks a lot!

@jssor Can I ask is this the main repo for JSSOR ? It seems very strange the setup here! You got a minify version only. How are people meant to work on the code if it's just a minify version here? You should have both, unminified and minified.

p.s. === and == do different things.

commented

not ready for some browsers yet, will change it in later version.