From df4c08a57a56764f55d30a2855f867e080367367 Mon Sep 17 00:00:00 2001 From: LA-MJ <4mr.minj@gmail.com> Date: Sun, 18 Feb 2024 22:10:03 +0100 Subject: [PATCH] fix scope polution (#229) globalThis != window --- dist/gauge.coffee | 11 +++++++---- dist/gauge.js | 13 ++++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/dist/gauge.coffee b/dist/gauge.coffee index 5f41a68..a7feb5a 100644 --- a/dist/gauge.coffee +++ b/dist/gauge.coffee @@ -12,7 +12,7 @@ do () -> lastId = 0 isCancelled = {} - if not requestAnimationFrame + if not window.requestAnimationFrame window.requestAnimationFrame = (callback, element) -> currTime = new Date().getTime() timeToCall = Math.max(0, 16 - (currTime - lastTime)) @@ -676,7 +676,7 @@ class Donut extends BaseDonut @options.strokeColor = @strokeGradient(w, h, start, stop) return @ -window.AnimationUpdater = +AnimationUpdater = elements: [] animId: null @@ -720,7 +720,8 @@ if typeof window.define == 'function' && window.define.amd? Gauge: Gauge, Donut: Donut, BaseDonut: BaseDonut, - TextRenderer: TextRenderer + TextRenderer: TextRenderer, + AnimationUpdater: AnimationUpdater } ) else if typeof module != 'undefined' && module.exports? @@ -728,10 +729,12 @@ else if typeof module != 'undefined' && module.exports? Gauge: Gauge, Donut: Donut, BaseDonut: BaseDonut, - TextRenderer: TextRenderer + TextRenderer: TextRenderer, + AnimationUpdater: AnimationUpdater } else window.Gauge = Gauge window.Donut = Donut window.BaseDonut = BaseDonut window.TextRenderer = TextRenderer + window.AnimationUpdater = AnimationUpdater diff --git a/dist/gauge.js b/dist/gauge.js index cfc1f8d..419b684 100644 --- a/dist/gauge.js +++ b/dist/gauge.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript 1.12.7 (function() { - var AnimatedText, AnimatedTextFactory, Bar, BaseDonut, BaseGauge, Donut, Gauge, GaugePointer, TextRenderer, ValueUpdater, addCommas, cutHex, formatNumber, mergeObjects, secondsToString, + var AnimatedText, AnimatedTextFactory, AnimationUpdater, Bar, BaseDonut, BaseGauge, Donut, Gauge, GaugePointer, TextRenderer, ValueUpdater, addCommas, cutHex, formatNumber, mergeObjects, secondsToString, slice = [].slice, hasProp = {}.hasOwnProperty, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, @@ -20,7 +20,7 @@ browserRequestAnimationFrame = null; lastId = 0; isCancelled = {}; - if (!requestAnimationFrame) { + if (!window.requestAnimationFrame) { window.requestAnimationFrame = function(callback, element) { var currTime, id, lastTime, timeToCall; currTime = new Date().getTime(); @@ -914,7 +914,7 @@ })(BaseDonut); - window.AnimationUpdater = { + AnimationUpdater = { elements: [], animId: null, addAll: function(list) { @@ -969,7 +969,8 @@ Gauge: Gauge, Donut: Donut, BaseDonut: BaseDonut, - TextRenderer: TextRenderer + TextRenderer: TextRenderer, + AnimationUpdater: AnimationUpdater }; }); } else if (typeof module !== 'undefined' && (module.exports != null)) { @@ -977,13 +978,15 @@ Gauge: Gauge, Donut: Donut, BaseDonut: BaseDonut, - TextRenderer: TextRenderer + TextRenderer: TextRenderer, + AnimationUpdater: AnimationUpdater }; } else { window.Gauge = Gauge; window.Donut = Donut; window.BaseDonut = BaseDonut; window.TextRenderer = TextRenderer; + window.AnimationUpdater = AnimationUpdater; } }).call(this);