fix(sw) register: null -> stub

This commit is contained in:
coderaiser 2018-09-21 17:28:56 +03:00
parent 95c160ca55
commit 2d7722c19f

View file

@ -3,6 +3,8 @@
module.exports.registerSW = registerSW;
module.exports.unregisterSW = unregisterSW;
const noop = () => {};
async function registerSW(prefix) {
prefix = prefix ? `/${prefix}/` : `/`;
@ -13,7 +15,9 @@ async function registerSW(prefix) {
const isLocalhost = location.hostname === 'localhost';
if (!isHTTPS && !isLocalhost)
return;
return {
addEventListener: noop,
};
return navigator.serviceWorker.register(`${prefix}sw.js`);
}