Skip to content

Commit 6d95977

Browse files
Peter BengtssonTimer
Peter Bengtsson
authored andcommitted
avoid TypeError on when registering service workers without config (facebook#5301)
* avoid TypeError on when registering service workers without config Fixes facebook#5299 * same before config.onUpdate
1 parent f6c61b8 commit 6d95977

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

template/src/serviceWorker.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function registerValidSW(swUrl, config) {
6868
console.log('New content is available; please refresh.');
6969

7070
// Execute callback
71-
if (config.onUpdate) {
71+
if (config && config.onUpdate) {
7272
config.onUpdate(registration);
7373
}
7474
} else {
@@ -78,7 +78,7 @@ function registerValidSW(swUrl, config) {
7878
console.log('Content is cached for offline use.');
7979

8080
// Execute callback
81-
if (config.onSuccess) {
81+
if (config && config.onSuccess) {
8282
config.onSuccess(registration);
8383
}
8484
}

0 commit comments

Comments
 (0)