Skip to content

Commit 1fe94cb

Browse files
committed
chore: refactored some aspects out of xo feedback
1 parent 09bd761 commit 1fe94cb

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

loading-attribute-polyfill.sw.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
self.addEventListener('fetch', (event) => {
2-
const requestURLParams = new URL(event.request.url).searchParams,
3-
swURLSearchparams = new URL(self.location.href).searchParams;
2+
const requestURLParameters = new URL(event.request.url).searchParams;
3+
const swURLSearchparams = new URL(self.location.href).searchParams;
44

55
if (
6-
requestURLParams.get('loading') &&
7-
requestURLParams.get('loading') === 'lazy'
6+
requestURLParameters.get('loading') &&
7+
requestURLParameters.get('loading') === 'lazy'
88
) {
99
if (event.request.destination === 'iframe') {
1010
if (swURLSearchparams.get('loading-iframes') !== 'true') {
@@ -18,16 +18,17 @@ self.addEventListener('fetch', (event) => {
1818
event.respondWith(
1919
new Response(
2020
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ' +
21-
requestURLParams.get('image-width') +
21+
requestURLParameters.get('image-width') +
2222
' ' +
23-
requestURLParams.get('image-height') +
23+
requestURLParameters.get('image-height') +
2424
'"></svg>',
2525
{
2626
headers: { 'Content-Type': 'image/svg+xml' },
2727
}
2828
)
2929
);
3030
}
31+
3132
return;
3233
}
3334
});

0 commit comments

Comments
 (0)