Skip to content

Commit dce13ef

Browse files
committed
Check if the window.performance should be used in a duck-typy way
In my Rollup setup, there is a fake `global` object that is a reference to `window`, which means that the polyfill (meant for Node.js) will be used instead of `window.performance`. I'd rather check if `window` exists and has a `performance()` method, and then only use the polyfill if it's not the case.
1 parent 90b3ba1 commit dce13ef

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/performance.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let perf = null, start = Date.now();
55

66
// use global browser performance module
77
// for node create a polyfill
8-
if (!global) {
8+
if (typeof window !== 'undefined' && window.performance) {
99
perf = window.performance;
1010
} else {
1111
perf = {
@@ -15,4 +15,4 @@ if (!global) {
1515
};
1616
}
1717

18-
export default perf;
18+
export default perf;

0 commit comments

Comments
 (0)