Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marker element click event throws: Uncaught TypeError: Cannot read property 'x' of null #7864

Closed
ParryQiu opened this issue Feb 1, 2019 · 7 comments · Fixed by #8462
Closed

Comments

@ParryQiu
Copy link

ParryQiu commented Feb 1, 2019

mapbox-gl-js version: 0.52.0

browser: macOS Chrome Version 71.0.3578.98 (Official Build) (64-bit)

Steps to Trigger Behavior

  1. add a html marker;
  2. add event by addEventListener to marker's html dom;
  3. fire the event, throws the error: Uncaught TypeError: Cannot read property 'x' of null

Link to Demonstration

https://jsfiddle.net/ParryQiu/hnkwqfue/12/

console out put error:

vendor.js:51848 ERROR TypeError: Cannot read property 'x' of null
    at a.equals (vendor.js:18268)
    at HTMLDivElement.<anonymous> (vendor.js:18272)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.js:2745)
    at Object.onInvokeTask (vendor.js:53986)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.js:2744)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (polyfills.js:2517)
    at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (polyfills.js:2820)
    at invokeTask (polyfills.js:4066)
    at HTMLDivElement.globalZoneAwareCallback (polyfills.js:4092)
    at Map.<anonymous> (main.js:7314)
@ParryQiu ParryQiu changed the title Marker element click event throws error: Uncaught TypeError: Cannot read property 'x' of null Marker element click event throws: Uncaught TypeError: Cannot read property 'x' of null Feb 1, 2019
@cs09g
Copy link
Contributor

cs09g commented Feb 1, 2019

Because startPos set when onMouseDown is triggered(bind_handlers.js#L155, L60). So, if click is triggered programatically, startPos is not set, then throw Error.

@mourner
Copy link
Member

mourner commented Feb 1, 2019

@cs09g good find! Want to submit a PR with the fix?

@cs09g
Copy link
Contributor

cs09g commented Feb 1, 2019

@mourner sure :) but I'm off about a week for holiday so, it would be taking a week.

@ParryQiu
Copy link
Author

ParryQiu commented Feb 2, 2019

@cs09g Thanks very much, I fixed this issue in local repository.
After doing some testing, consider submitting a PR.

@cs09g
Copy link
Contributor

cs09g commented Mar 14, 2019

@ParryQiu Are you able to commit the fix?

@phirschybar
Copy link

+1 - having the exact same issue on v 0.53.1 and only seeing it when triggering a marker click programmatically.

ParryQiu added a commit to ParryQiu/mapbox-gl-js that referenced this issue Mar 18, 2019
fixed if marker click is triggered programatically, throw the exception.
mapbox#7864
@ParryQiu
Copy link
Author

@cs09g
#8049

msbarry added a commit to msbarry/mapbox-gl-js that referenced this issue Jul 11, 2019
mourner pushed a commit that referenced this issue Jul 11, 2019
* Add check for startPos to fix #7864

* add test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants