Check if windowResize argument is undefined

When loading nv3d without creating a chart, ```nv.utils.windowResize``` is called somewhere with an undefined argument, so we should check if it is undefined and not try to replace the old event handler, otherwise every resize event generates an error because ```fun``` is undefined.

I was able to produce  by including the following libs and triggering onresize events.

```
nvd3/lib/d3.v2.js
nvd3/src/core.js
nvd3/src/tooltip.js
nvd3/src/utils.js
nvd3/src/models/lineWithFocusChart.js
nvd3/src/models/legend.js
nvd3/src/models/axis.js
nvd3/src/models/line.js
nvd3/src/models/scatter.js
```

Sponsored-by: CentroNet Marketing
master-patched^2
Michael J. Cohen 11 years ago
parent 7e9b8c013c
commit 5650e9cde9

@ -30,6 +30,7 @@ nv.utils.windowSize = function() {
// Easy way to bind multiple functions to window.onresize
// TODO: give a way to remove a function after its bound, other than removing all of them
nv.utils.windowResize = function(fun){
if (fun === undefined) return;
var oldresize = window.onresize;
window.onresize = function(e) {

Loading…
Cancel
Save