Skip to content

Commit e8ab0da

Browse files
authored
fix(platform): don't shadow window (#4622)
1 parent 3ae0dc6 commit e8ab0da

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/lib/core/platform/platform.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import {Injectable} from '@angular/core';
22

3-
declare const window: any;
4-
53
// Whether the current platform supports the V8 Break Iterator. The V8 check
64
// is necessary to detect all Blink based browsers.
7-
const hasV8BreakIterator = typeof(window) !== 'undefined' ?
8-
(window.Intl && (window.Intl as any).v8BreakIterator) :
9-
(typeof(Intl) !== 'undefined' && (Intl as any).v8BreakIterator);
5+
const hasV8BreakIterator = (typeof(Intl) !== 'undefined' && (Intl as any).v8BreakIterator);
106

117
/**
128
* Service to detect the current platform by comparing the userAgent strings and
@@ -22,14 +18,14 @@ export class Platform {
2218
TRIDENT = /(msie|trident)/i.test(navigator.userAgent);
2319

2420
// EdgeHTML and Trident mock Blink specific things and need to be excluded from this check.
25-
BLINK = !!(window.chrome || hasV8BreakIterator) && !!CSS && !this.EDGE && !this.TRIDENT;
21+
BLINK = !!((window as any).chrome || hasV8BreakIterator) && !!CSS && !this.EDGE && !this.TRIDENT;
2622

2723
// Webkit is part of the userAgent in EdgeHTML, Blink and Trident. Therefore we need to
2824
// ensure that Webkit runs standalone and is not used as another engine's base.
2925
WEBKIT = /AppleWebKit/i.test(navigator.userAgent) && !this.BLINK && !this.EDGE && !this.TRIDENT;
3026

3127
/** Browsers and Platform Types */
32-
IOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
28+
IOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !(window as any).MSStream;
3329

3430
// It's difficult to detect the plain Gecko engine, because most of the browsers identify
3531
// them self as Gecko-like browsers and modify the userAgent's according to that.

0 commit comments

Comments
 (0)