From 6d95977354244a9a73a0ac01e26db04d1bda535f Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Thu, 4 Oct 2018 22:42:16 -0400 Subject: [PATCH] avoid TypeError on when registering service workers without config (#5301) * avoid TypeError on when registering service workers without config Fixes #5299 * same before config.onUpdate --- template/src/serviceWorker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/src/serviceWorker.js b/template/src/serviceWorker.js index 8859a0c6b20..46c98a44037 100644 --- a/template/src/serviceWorker.js +++ b/template/src/serviceWorker.js @@ -68,7 +68,7 @@ function registerValidSW(swUrl, config) { console.log('New content is available; please refresh.'); // Execute callback - if (config.onUpdate) { + if (config && config.onUpdate) { config.onUpdate(registration); } } else { @@ -78,7 +78,7 @@ function registerValidSW(swUrl, config) { console.log('Content is cached for offline use.'); // Execute callback - if (config.onSuccess) { + if (config && config.onSuccess) { config.onSuccess(registration); } }