From 3b044de7d9816bd6579ebb7e8010ffc9f5c8cf34 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 15 Jul 2021 10:41:33 -0700 Subject: [PATCH] Use Workbox convention for skip waiting message --- wp-includes/js/service-worker.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wp-includes/js/service-worker.js b/wp-includes/js/service-worker.js index 25e396509..2fedb75cc 100644 --- a/wp-includes/js/service-worker.js +++ b/wp-includes/js/service-worker.js @@ -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(); } });