]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Avoid errors when rendering serverside (#3909)
authorBohdan Khorolets <bogdan@khorolets.com>
Tue, 21 Mar 2017 00:37:34 +0000 (02:37 +0200)
committerEvert Timberg <evert.timberg+github@gmail.com>
Tue, 21 Mar 2017 00:37:34 +0000 (20:37 -0400)
src/chart.js
src/core/core.helpers.js

index 0ee96bd57d43279e135ec124d2f3d83ae2210a20..591572110e89bedd1187adbfe574908ff0e69c0c 100644 (file)
@@ -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;
+}
index 2d96ac14b47a8e1c692d0c256f8fb991ee248d30..5ed5c28edd4b1f89888969f9ceeccde7f122ec7e 100644 (file)
@@ -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 ||