From 434151b5b3368920dc7add2a28d8da172cb70060 Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Sun, 14 May 2017 20:38:36 +0000
Subject: [PATCH] Do not call skipWaiting on inactive service worker

---
 serviceworker-install.js |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/serviceworker-install.js b/serviceworker-install.js
index 1d3d1b5..bb1fd28 100644
--- a/serviceworker-install.js
+++ b/serviceworker-install.js
@@ -2,7 +2,9 @@
 	window.addEventListener('load', function() {
 		navigator.serviceWorker.register('/serviceworker.js').then(function(registration) {
 			console.log('Service Worker registration successful. ', registration);
-			navigator.serviceWorker.controller.postMessage({action: 'skipWaiting'});
+			if(navigator.serviceWorker.controller) {
+				navigator.serviceWorker.controller.postMessage({action: 'skipWaiting'});
+			}
 		}).catch(function(err) {
 			console.log('Service Worker registration failed. ', err);
 		});

--
Gitblit v1.9.1