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

Patch map.fire to format arguments passed to it. #772

Merged
merged 1 commit into from
May 2, 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 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ cache:
- node_modules
node_js:
- "6"
env:
- NODE_ENV=test
deploy:
provider: s3
access_key_id:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Install dependencies, build the source files and crank up a server via:
```
git clone [email protected]:mapbox/mapbox-gl-draw.git
npm install
npm start & open http://localhost:9966/debug/?access_token=<token>
npm start & open http://localhost:9967/debug/?access_token=<token>
```

### Testing
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
"style": "dist/mapbox-gl-draw.css",
"browserify": {
"transform": [
"envify",
"babelify"
]
},
"scripts": {
"docs": "npm run docs-modes-life-cycle && npm run docs-modes-get-and-set",
"docs-modes-get-and-set": "documentation readme --readme-file ./docs/MODES.md -s \"Setters and Getters\" src/modes/mode_interface_accessors.js --shallow",
"docs-modes-life-cycle": "documentation readme --readme-file ./docs/MODES.md -s \"Life Cycle Functions\" src/modes/mode_interface.js --shallow",
"test": "npm run lint && npm run tape",
"test": "NODE_ENV=test npm run lint && npm run tape",
"lint": "eslint --no-eslintrc -c .eslintrc index.js src test",
"tape": "tape -r ./test/mock-browser.js -r babel-register test/*.test.js",
"coverage": "NODE_ENV=test nyc --reporter html npm run tape && opener coverage/index.html",
Expand Down Expand Up @@ -57,18 +58,18 @@
"eslint-config-mourner": "^2.0.1",
"express": "^4.13.4",
"mapbox-gl": "0.41.0",
"mapbox-gl-js-mock": "^0.28.0",
"mapbox-gl-js-mock": "0.28.0",
"mock-browser": "^0.92.10",
"nyc": "^11.0.2",
"opener": "^1.4.1",
"sinon": "^5.0.0",
"synthetic-dom-events": "^0.3.0",
"sinon": "5.0.0",
"synthetic-dom-events": "0.3.0",
"tape": "^4.0.0",
"uglify-js": "^3.0.22",
"unassertify": "^2.0.3"
},
"peerDependencies": {
"mapbox-gl": ">=0.27.0 <=0.41.0"
"mapbox-gl": ">=0.27.0 <=0.45.0"
},
"dependencies": {
"@mapbox/geojson-area": "^0.2.1",
Expand Down
16 changes: 16 additions & 0 deletions src/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const events = require('./events');
const Store = require('./store');
const ui = require('./ui');
const Constants = require('./constants');
const xtend = require('xtend');

module.exports = function(ctx) {

Expand Down Expand Up @@ -35,6 +36,21 @@ module.exports = function(ctx) {
ctx.events.addEventListeners();
},
onAdd: function(map) {
if (process.env.NODE_ENV !== 'test') {
// Monkey patch to resolve breaking change to `fire` introduced by
// mapbox-gl-js. See mapbox/mapbox-gl-draw/issues/766.
const _fire = map.fire;
map.fire = function(type, event) {
let args = arguments;

if (_fire.length === 1 && arguments.length !== 1) {
args = [xtend({}, { type: type }, event)];
}

return _fire.apply(map, args);
};
}

ctx.map = map;
ctx.events = events(ctx);
ctx.ui = ui(ctx);
Expand Down
2 changes: 1 addition & 1 deletion src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ Store.prototype.restoreMapConfig = function() {
/**
* Returns the initial state of an interaction setting.
* @param {string} interaction
* @return {boolean} `true` if the interaction is enabled, `false` if not.
* @return {boolean} `true` if the interaction is enabled, `false` if not.
* Defaults to `true`. (Todo: include defaults.)
*/
Store.prototype.getInitialConfigValue = function(interaction) {
Expand Down
Loading