small fix in init_service_worker#5417
Conversation
fix: Replaced arrow function with anonymous function in the init_service_worker script for support old browsers
🦋 Changeset detectedLatest commit: 778c4c4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
I'm curious how you're getting the rest of the app to work, since we're using |
It looks like the app.html <body>
<div>%sveltekit.body%</div>
<script src="/lib/polyfills/shimport/polyfill.js"></script>
</body>/lib/polyfills/shimport/polyfill.js try {
new Function("if(0)import('')")();
} catch (e) {
var scripts = document.querySelectorAll('script[type=module]');
for (var i = 0; i < scripts.length; i++){
var script = scripts[i];
var newScript = document.createElement("script");
var attributes = script.attributes;
for (var j = 0; j < attributes.length; j++){
var attribute = attributes[j];
if (attribute.name !== 'type' && attribute.name !== 'src') {
newScript.setAttribute(attribute.name, attribute.value);
}
}
var blob = new Blob([script.innerText], {
type: 'application/javascript'
});
newScript.setAttribute("data-main", URL.createObjectURL(blob));
newScript.src = "/lib/polyfills/shimport/shimport@2.0.5.dev.js";
script.parentNode.insertBefore(newScript, script);
script.remove();
}
} |
|
Thanks — since a more comprehensive fix would take time, I think it makes sense to merge this to unblock you, but I added a comment to make a regression less likely — details in https://github.com/sveltejs/kit/pull/5417/files#r916857155 |
Replaced arrow function with anonymous function in the init_service_worker script for support old browsers
This is necessary for the application to work in WebView on Android >= 5.1 (Chromium >= 39).
Arrow functions are only supported in Android WebView >= 45, see MDN
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. All changesets should bepatchuntil SvelteKit 1.0