Skip to content

Commit 23ce6fa

Browse files
authored
fix(hydrate): avoid window reference (#18865)
1 parent a8455a9 commit 23ce6fa

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

angular/src/util/util.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import { HTMLStencilElement } from '../types/interfaces';
22

3+
declare const __zone_symbol__requestAnimationFrame: any;
4+
declare const requestAnimationFrame: any;
5+
36
export const raf = (h: any) => {
4-
const win = window as any;
5-
return (win.__zone_symbol__requestAnimationFrame) ? win.__zone_symbol__requestAnimationFrame(h) : requestAnimationFrame(h);
7+
if (typeof __zone_symbol__requestAnimationFrame === 'function') {
8+
return __zone_symbol__requestAnimationFrame(h);
9+
}
10+
if (typeof requestAnimationFrame === 'function') {
11+
return requestAnimationFrame(h);
12+
}
13+
return setTimeout(h);
614
};
715

816
export const proxyMethod = (ctrlName: string, doc: Document, methodName: string, ...args: any[]) => {

0 commit comments

Comments
 (0)