mikolalysenko / mouse-change

Mouse state change listener
https://mikolalysenko.github.io/mouse-change
MIT License
15 stars 1 forks source link

Cannot instiatiate with element but without callback #3

Open joepie91 opened 5 years ago

joepie91 commented 5 years ago

This snippet of code attempts to shift the callback argument into place when an element is omitted, but it seems to unintentionally break the scenario where you only provide an element.

Possible cases:

IMO the ideal change would be not to try and magically infer arguments like this, but rather accept an object of optional options. That'd be a breaking change, though.

The quicker (and non-breaking) patch would be to shift the argument only if the 'element' is a function and the callback is unset.