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

deregister marker mouseup and touchend when removing marker #7442

Merged
merged 1 commit into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ui/marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ export default class Marker extends Evented {
this._map.off('moveend', this._update);
this._map.off('mousedown', this._addDragHandler);
this._map.off('touchstart', this._addDragHandler);
this._map.off('mouseup', this._onUp);
this._map.off('touchend', this._onUp);
delete this._map;
}
DOM.remove(this._element);
Expand Down
14 changes: 14 additions & 0 deletions test/unit/ui/marker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,3 +451,17 @@ test('Marker with draggable:false does not move to new position in response to a
map.remove();
t.end();
});

test('Marker with draggable:true does not error if removed on mousedown', (t) => {
const map = createMap(t);
const marker = new Marker({draggable: true})
.setLngLat([0, 0])
.addTo(map);
const el = marker.getElement();
simulate.mousedown(el);
simulate.mousemove(el, {clientX: 10, clientY: 10});

marker.remove();
t.ok(map.fire('mouseup'));
t.end();
});