-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
small fix in init_service_worker #5417
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 test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0