Skip to content

Commit 4279a01

Browse files
authored
Merge pull request #2001 from WordPress/add/win-aliases
Use `win` and `doc` aliases consistently
2 parents ec4941d + a843357 commit 4279a01

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

plugins/optimization-detective/detect.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ async function getAlreadySubmittedSessionStorageKey(
244244
urlMetricGroupStatus,
245245
{ warn, error }
246246
) {
247-
if ( ! window.crypto || ! window.crypto.subtle ) {
247+
if ( ! win.crypto || ! win.crypto.subtle ) {
248248
warn(
249249
'Unable to generate sessionStorage key for already-submitted URL since crypto is not available, likely due to to the page not being served via HTTPS.'
250250
);
@@ -580,7 +580,7 @@ export default async function detect( {
580580
return;
581581
}
582582

583-
if ( document.visibilityState === 'hidden' && ! document.prerendering ) {
583+
if ( doc.visibilityState === 'hidden' && ! doc.prerendering ) {
584584
log( 'Page opened in background tab so URL Metric is not collected.' );
585585
return;
586586
}
@@ -671,7 +671,7 @@ export default async function detect( {
671671

672672
// Keep track of whether the window resized. If it was resized, we abort sending the URLMetric.
673673
let didWindowResize = false;
674-
window.addEventListener(
674+
win.addEventListener(
675675
'resize',
676676
() => {
677677
didWindowResize = true;
@@ -927,7 +927,7 @@ export default async function detect( {
927927
doc.addEventListener(
928928
'visibilitychange',
929929
() => {
930-
if ( document.visibilityState === 'hidden' ) {
930+
if ( doc.visibilityState === 'hidden' ) {
931931
// TODO: This will fire even when switching tabs.
932932
resolve();
933933
}

0 commit comments

Comments
 (0)