From c6780edd0c08f2824222a9e15a40443e33d2507d Mon Sep 17 00:00:00 2001 From: Matt Hinchliffe Date: Tue, 20 Jun 2017 13:06:13 +0100 Subject: [PATCH] Bugfix: bail if startAds method is called multiple times (V3) (#108) * Bugfix: bail if startAds method is called multiple times * Check loading spinner exists before attempting to remove it --- src/js/ads.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/js/ads.js b/src/js/ads.js index 3158912..d82629e 100644 --- a/src/js/ads.js +++ b/src/js/ads.js @@ -187,8 +187,10 @@ class VideoAds { } // Remove the preloading spinner - this.loadingStateEl.parentNode.removeChild(this.loadingStateEl); - this.loadingStateEl = null; + if (this.loadingStateEl) { + this.loadingStateEl.parentNode.removeChild(this.loadingStateEl); + this.loadingStateEl = null; + } try { // Initialize the ads manager. Ad rules playlist will start at this time.