Skip to content

Commit

Permalink
More permissive support for the className prop of Map
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulLeCam committed Nov 27, 2017
1 parent f1f1123 commit 19cde6e
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 103 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v1.7.7 (2017-11-27)

* More permissive support for the `className` prop of `Map`.

## v1.7.6 (2017-11-23)

* Fixed supporting `Popup` children in `CircleMarker`.
Expand Down
25 changes: 10 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"build:umd": "cross-env BABEL_ENV=rollup NODE_ENV=development rollup -c",
"build:umd:min": "cross-env BABEL_ENV=rollup NODE_ENV=production rollup -c",
"build:flow": "flow-copy-source src lib && flow-copy-source src es",
"build": "npm run clean && npm run build:cjs && npm run build:es && npm run build:flow && npm run build:umd && npm run build:umd:min",
"build":
"npm run clean && npm run build:cjs && npm run build:es && npm run build:flow && npm run build:umd && npm run build:umd:min",
"jest": "cross-env BABEL_ENV=development NODE_ENV=test jest",
"jest:watch": "cross-env BABEL_ENV=development NODE_ENV=test jest --watch",
"lint": "eslint ./src",
Expand All @@ -21,18 +22,14 @@
"test:watch": "npm run lint && npm run flow && npm run jest:watch",
"start": "npm run test && npm run build",
"prepublishOnly": "npm run build",
"examples": "webpack-dev-server --config ./example/webpack.config.babel.js --progress"
"examples":
"webpack-dev-server --config ./example/webpack.config.babel.js --progress"
},
"repository": {
"type": "git",
"url": "https://github.com/PaulLeCam/react-leaflet.git"
},
"keywords": [
"react-component",
"react",
"leaflet",
"map"
],
"keywords": ["react-component", "react", "leaflet", "map"],
"author": "Paul Le Cam <[email protected]>",
"license": "MIT",
"bugs": {
Expand Down Expand Up @@ -64,8 +61,8 @@
"babel-preset-react": "^6.24.1",
"babel-preset-stage-1": "^6.24.1",
"cross-env": "^5.1.1",
"eslint": "^4.11.0",
"eslint-config-prettier": "^2.8.0",
"eslint": "^4.12.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-flowtype": "^2.39.1",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^5.2.1",
Expand All @@ -83,20 +80,18 @@
"react": "^16.1.1",
"react-dom": "^16.1.1",
"rimraf": "^2.6.2",
"rollup": "^0.51.8",
"rollup": "^0.52.0",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-commonjs": "^8.2.6",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-uglify": "^2.0.1",
"webpack": "^3.8.1",
"webpack-dev-server": "^2.9.4"
"webpack-dev-server": "^2.9.5"
},
"jest": {
"collectCoverage": true,
"setupFiles": [
"raf/polyfill"
],
"setupFiles": ["raf/polyfill"],
"transform": {
".*": "<rootDir>/node_modules/babel-jest"
}
Expand Down
14 changes: 7 additions & 7 deletions src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const OTHER_PROPS = [
'whenReady',
]

const normalizeCenter = (pos: LatLng): [number, number] => {
return Array.isArray(pos)
? [pos[0], pos[1]]
: [pos.lat, pos.lon ? pos.lon : pos.lng]
}
const normalizeCenter = (pos: LatLng): [number, number] =>
Array.isArray(pos) ? [pos[0], pos[1]] : [pos.lat, pos.lon ? pos.lon : pos.lng]

const splitClassName = (className: string = ''): Array<string> =>
className.split(' ').filter(Boolean)

type LeafletElement = LeafletMap

Expand Down Expand Up @@ -177,12 +177,12 @@ export default class Map extends MapComponent<LeafletElement, Props> {

if (className !== fromProps.className) {
if (fromProps.className != null && fromProps.className.length > 0) {
forEach(fromProps.className.split(' '), cls => {
forEach(splitClassName(fromProps.className), cls => {
DomUtil.removeClass(this.container, cls)
})
}
if (className != null && className.length > 0) {
forEach(className.split(' '), cls => {
forEach(splitClassName(className), cls => {
DomUtil.addClass(this.container, cls)
})
}
Expand Down
Loading

0 comments on commit 19cde6e

Please sign in to comment.