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
This commit is contained in:
Peter Bengtsson
2018-10-04 22:42:16 -04:00
committed by Joe Haddad
parent ea15ebad8f
commit e783bf8aed

View File

@@ -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);
}
}