fix(sw): guard navigator.serviceWorker access before feature check; fix EOF newline
Accessing navigator.serviceWorker.controller before the 'serviceWorker' in navigator guard would throw a TypeError on browsers without SW support. Moved the guard into the had_controller expression so the property is never accessed on unsupported browsers. Also adds the missing trailing newline to core__export.ts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -346,7 +346,9 @@ $effect(() => {
|
||||
// Added 2026-06-22 to close this gap.
|
||||
// Capture before registering — if null, this is first activation (fresh page load)
|
||||
// and the reload is unnecessary since assets were already fetched without the SW.
|
||||
const had_controller = !!navigator.serviceWorker.controller;
|
||||
// Guard must be part of the expression: navigator.serviceWorker doesn't exist on
|
||||
// browsers without SW support, so accessing .controller before checking would throw.
|
||||
const had_controller = 'serviceWorker' in navigator && !!navigator.serviceWorker.controller;
|
||||
const on_controller_change = () => {
|
||||
if (had_controller) window.location.reload();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user