From da1d1ca5125b7fc6e90dd49b0656f3d82311e8e7 Mon Sep 17 00:00:00 2001 From: Bohdan Khorolets Date: Tue, 21 Mar 2017 02:37:34 +0200 Subject: [PATCH] Avoid errors when rendering serverside (#3909) --- src/chart.js | 5 ++++- src/core/core.helpers.js | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/chart.js b/src/chart.js index 0ee96bd57..591572110 100644 --- a/src/chart.js +++ b/src/chart.js @@ -56,4 +56,7 @@ plugins.push(require('./plugins/plugin.filler.js')(Chart)); Chart.plugins.register(plugins); -window.Chart = module.exports = Chart; +module.exports = Chart; +if (typeof window !== 'undefined') { + window.Chart = Chart; +} diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 2d96ac14b..5ed5c28ed 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -669,6 +669,11 @@ module.exports = function(Chart) { }; // Request animation polyfill - http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ helpers.requestAnimFrame = (function() { + if (typeof window === 'undefined') { + return function(callback) { + callback(); + }; + } return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || -- 2.47.3