Skip to content

Commit d9dfeb2

Browse files
committed
Patch map.fire to format arguments passed to it.
1 parent 85f39bf commit d9dfeb2

File tree

4 files changed

+2072
-155
lines changed

4 files changed

+2072
-155
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Install dependencies, build the source files and crank up a server via:
8484
```
8585
git clone [email protected]:mapbox/mapbox-gl-draw.git
8686
npm install
87-
npm start & open http://localhost:9966/debug/?access_token=<token>
87+
npm start & open http://localhost:9967/debug/?access_token=<token>
8888
```
8989

9090
### Testing

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"unassertify": "^2.0.3"
6969
},
7070
"peerDependencies": {
71-
"mapbox-gl": ">=0.27.0 <=0.41.0"
71+
"mapbox-gl": ">=0.27.0 <=0.45.0"
7272
},
7373
"dependencies": {
7474
"@mapbox/geojson-area": "^0.2.1",

src/setup.js

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const events = require('./events');
22
const Store = require('./store');
33
const ui = require('./ui');
44
const Constants = require('./constants');
5+
const xtend = require('xtend');
56

67
module.exports = function(ctx) {
78

@@ -35,6 +36,20 @@ module.exports = function(ctx) {
3536
ctx.events.addEventListeners();
3637
},
3738
onAdd: function(map) {
39+
40+
// Monkey patch to resolve breaking change to `fire` introduced by
41+
// mapbox-gl-js. See mapbox/mapbox-gl-draw/issues/766.
42+
const _fire = map.fire;
43+
map.fire = function(type, event) {
44+
let args = arguments;
45+
46+
if (_fire.length === 1 && arguments.length !== 1) {
47+
args = [xtend({}, { type: type }, event)];
48+
}
49+
50+
return _fire.apply(map, args);
51+
};
52+
3853
ctx.map = map;
3954
ctx.events = events(ctx);
4055
ctx.ui = ui(ctx);

0 commit comments

Comments
 (0)