Skip to content

Commit 582dfae

Browse files
committed
Patch map.fire to format arguments passed to it.
Ref #766
1 parent 85f39bf commit 582dfae

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
"eslint": "^4.2.0",
5757
"eslint-config-mourner": "^2.0.1",
5858
"express": "^4.13.4",
59-
"mapbox-gl": "0.41.0",
60-
"mapbox-gl-js-mock": "^0.28.0",
59+
"mapbox-gl": "0.45.0-beta.1",
60+
"mapbox-gl-js-mock": "^1.0.2",
6161
"mock-browser": "^0.92.10",
6262
"nyc": "^11.0.2",
6363
"opener": "^1.4.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)