Skip to content

Commit

Permalink
Use Workbox convention for skip waiting message
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Aug 23, 2021
1 parent 64d5d2f commit 3b044de
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion wp-includes/js/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ wp.serviceWorker = workbox;
* mechanism for clients to skip waiting if they want to.
*/
self.addEventListener('message', function (event) {
if ('skipWaiting' === event.data.action) {
if (!event.data) {
return;
}
if (
// De facto standard used by Workbox.
event.data.type === 'SKIP_WAITING' ||
// Obsolete message sent in older versions of the plugin.
'skipWaiting' === event.data.action
) {
self.skipWaiting();
}
});

0 comments on commit 3b044de

Please sign in to comment.