Skip to content

Commit 2803e51

Browse files
committed
s/self/WINDOW
1 parent 5aea7f1 commit 2803e51

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

packages/browser-utils/src/metrics/web-vitals/getINP.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { WINDOW } from '../../types';
1718
import { bindReporter } from './lib/bindReporter';
1819
import { initMetric } from './lib/initMetric';
1920
import { DEFAULT_DURATION_THRESHOLD, estimateP98LongestInteraction, processInteractionEntry } from './lib/interactions';
@@ -57,7 +58,7 @@ export const INPThresholds: MetricRatingThresholds = [200, 500];
5758
*/
5859
export const onINP = (onReport: (metric: INPMetric) => void, opts: ReportOpts = {}) => {
5960
// Return if the browser doesn't support all APIs needed to measure INP.
60-
if (!('PerformanceEventTiming' in self && 'interactionId' in PerformanceEventTiming.prototype)) {
61+
if (!('PerformanceEventTiming' in WINDOW && 'interactionId' in PerformanceEventTiming.prototype)) {
6162
return;
6263
}
6364

packages/browser-utils/src/metrics/web-vitals/lib/getNavigationEntry.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { WINDOW } from '../../../types';
18+
1719
export const getNavigationEntry = (): PerformanceNavigationTiming | void => {
1820
const navigationEntry =
19-
self.performance && performance.getEntriesByType && performance.getEntriesByType('navigation')[0];
21+
WINDOW.performance && WINDOW.performance.getEntriesByType && WINDOW.performance.getEntriesByType('navigation')[0];
2022

2123
// Check to ensure the `responseStart` property is present and valid.
2224
// In some cases no value is reported by the browser (for

packages/browser-utils/src/metrics/web-vitals/lib/whenIdle.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { runOnce } from './runOnce';
2323
* if the browser's visibility state is (or becomes) hidden.
2424
*/
2525
export const whenIdle = (cb: () => void): number => {
26-
const rIC = self.requestIdleCallback || self.setTimeout;
26+
const rIC = WINDOW.requestIdleCallback || WINDOW.setTimeout;
2727

2828
let handle = -1;
2929
// eslint-disable-next-line no-param-reassign

0 commit comments

Comments
 (0)