Skip to content

Commit

Permalink
small fix in init_service_worker (#5417)
Browse files Browse the repository at this point in the history
* Update render.js

fix: Replaced arrow function with anonymous function in the init_service_worker script for support old browsers

* Create ninety-dodos-exercise.md

* Update packages/kit/src/runtime/server/page/render.js

Co-authored-by: Rich Harris <hello@rich-harris.dev>
  • Loading branch information
NikolayMakhonin and Rich-Harris committed Jul 8, 2022
1 parent a5ee2ba commit e60a014
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/ninety-dodos-exercise.md
@@ -0,0 +1,5 @@
---
"@sveltejs/kit": patch
---

Use anonymous function in service worker init script to support legacy browsers
4 changes: 3 additions & 1 deletion packages/kit/src/runtime/server/page/render.js
Expand Up @@ -188,9 +188,11 @@ export async function render_response({
});
`;

// we use an anonymous function instead of an arrow function to support
// older browsers (https://github.com/sveltejs/kit/pull/5417)
const init_service_worker = `
if ('serviceWorker' in navigator) {
addEventListener('load', () => {
addEventListener('load', function () {
navigator.serviceWorker.register('${options.service_worker}');
});
}
Expand Down

0 comments on commit e60a014

Please sign in to comment.