diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 5364d191f8e..4266b2934c1 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -992,8 +992,10 @@ module.exports = function(Chart) { }; }; helpers.removeResizeListener = function(node) { - var hiddenIframe = node.querySelector('.chartjs-hidden-iframe'); - + var hiddenIframe = null; + if (node) { + hiddenIframe = node.querySelector('.chartjs-hidden-iframe'); + } // Remove the resize detect iframe if (hiddenIframe) { hiddenIframe.parentNode.removeChild(hiddenIframe); diff --git a/src/core/core.js b/src/core/core.js index 577db878e16..aa28690d7d0 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -52,11 +52,13 @@ module.exports = function() { me.controller = new Chart.Controller(me); // Always bind this so that if the responsive state changes we still work - helpers.addResizeListener(context.canvas.parentNode, function() { - if (me.controller && me.controller.config.options.responsive) { - me.controller.resize(); - } - }); + if (me.controller && me.controller.config.options.responsive) { + helpers.addResizeListener(context.canvas.parentNode, function() { + if (me.controller && me.controller.config.options.responsive) { + me.controller.resize(); + } + }); + } return me.controller ? me.controller : me;