feat(events): check if event instanceof MouseEvent for events type 'mouseover' 'mouseout' etc #5464
Labels
bug
Something isn't working
enhancement
New feature or request
PR is more than welcomed
Extra attention is needed
User Story
As a developer for a company using maplibre as map engine for their website, I am facing an issue from Sentry. After analysing this issue, it appears that some facebook bots are crawling our website. They're dispatching events on the page, and some of their events are MouseEvents (mouseover, mouseout etc...). But during maplibre event handling, it crashes with an Invalid LngLat object: (NaN, NaN) Error.
I found a way to reproduce it and I determined that it crashes because they dispatch Event and not MouseEvent.
There's an easy way to reproduce : https://codepen.io/ToHold/pen/dPbBPJX
I know this is not a bug, developers should use MouseEvent, but in this case, we can't change what these bots are doing, that's why I'm asking it as feature request.
Rationale
I've seen that we are not alone facing this issue.
It would be easy to fix, a simple if (!event instanceof MouseEvent) return; would fix it.
Impact
Without this simple check, map can throw an unhandled error.
The text was updated successfully, but these errors were encountered: