Skip to content

Commit

Permalink
s/this/map and evaluate arguments length
Browse files Browse the repository at this point in the history
  • Loading branch information
tristen committed May 1, 2018
1 parent b3b3fbb commit 64f34a0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@ module.exports = function(ctx) {
// mapbox-gl-js. See mapbox/mapbox-gl-draw/issues/766.
const _fire = map.fire;
map.fire = function(type, event) {

// Circumvent if type is not a string.
if (type !== 'string') return _fire;
if (arguments.length === 1) return _fire;

function patched() {
if (_fire.length === 1) {
_fire.apply(this, xtend({}, {type: type }, event));
_fire.apply(map, xtend({}, {type: type }, event));
} else {
// It's an older version of Mapbox GL JS
_fire.apply(this, type, event);
_fire.apply(map, type, event);
}
}

Expand Down

0 comments on commit 64f34a0

Please sign in to comment.