@@ -15,39 +15,47 @@ const hasV8BreakIterator = (typeof(Intl) !== 'undefined' && (Intl as any).v8Brea
15
15
/**
16
16
* Service to detect the current platform by comparing the userAgent strings and
17
17
* checking browser-specific global properties.
18
- * @docs -private
19
18
*/
20
19
@Injectable ( )
21
20
export class Platform {
21
+ /** Whether the Angular application is being rendered in the browser. */
22
22
isBrowser : boolean = typeof document === 'object' && ! ! document ;
23
23
24
- /** Layout Engines */
25
- EDGE = this . isBrowser && / ( e d g e ) / i. test ( navigator . userAgent ) ;
26
- TRIDENT = this . isBrowser && / ( m s i e | t r i d e n t ) / i. test ( navigator . userAgent ) ;
24
+ /** Whether the current browser is Microsoft Edge. */
25
+ EDGE : boolean = this . isBrowser && / ( e d g e ) / i. test ( navigator . userAgent ) ;
27
26
27
+ /** Whether the current rendering engine is Microsoft Trident. */
28
+ TRIDENT : boolean = this . isBrowser && / ( m s i e | t r i d e n t ) / i. test ( navigator . userAgent ) ;
29
+
30
+ /** Whether the current rendering engine is Blink. */
28
31
// EdgeHTML and Trident mock Blink specific things and need to be excluded from this check.
29
- BLINK = this . isBrowser &&
32
+ BLINK : boolean = this . isBrowser &&
30
33
( ! ! ( ( window as any ) . chrome || hasV8BreakIterator ) && ! ! CSS && ! this . EDGE && ! this . TRIDENT ) ;
31
34
35
+ /** Whether the current rendering engine is WebKit. */
32
36
// Webkit is part of the userAgent in EdgeHTML, Blink and Trident. Therefore we need to
33
37
// ensure that Webkit runs standalone and is not used as another engine's base.
34
- WEBKIT = this . isBrowser &&
38
+ WEBKIT : boolean = this . isBrowser &&
35
39
/ A p p l e W e b K i t / i. test ( navigator . userAgent ) && ! this . BLINK && ! this . EDGE && ! this . TRIDENT ;
36
40
37
- /** Browsers and Platform Types */
38
- IOS = this . isBrowser && / i P a d | i P h o n e | i P o d / . test ( navigator . userAgent ) && ! ( window as any ) . MSStream ;
41
+ /** Whether the current platform is Apple iOS. */
42
+ IOS : boolean = this . isBrowser && / i P a d | i P h o n e | i P o d / . test ( navigator . userAgent ) &&
43
+ ! ( window as any ) . MSStream ;
39
44
45
+ /** Whether the current browser is Firefox. */
40
46
// It's difficult to detect the plain Gecko engine, because most of the browsers identify
41
47
// them self as Gecko-like browsers and modify the userAgent's according to that.
42
48
// Since we only cover one explicit Firefox case, we can simply check for Firefox
43
49
// instead of having an unstable check for Gecko.
44
- FIREFOX = this . isBrowser && / ( f i r e f o x | m i n e f i e l d ) / i. test ( navigator . userAgent ) ;
50
+ FIREFOX : boolean = this . isBrowser && / ( f i r e f o x | m i n e f i e l d ) / i. test ( navigator . userAgent ) ;
45
51
52
+ /** Whether the current platform is Android. */
46
53
// Trident on mobile adds the android platform to the userAgent to trick detections.
47
- ANDROID = this . isBrowser && / a n d r o i d / i. test ( navigator . userAgent ) && ! this . TRIDENT ;
54
+ ANDROID : boolean = this . isBrowser && / a n d r o i d / i. test ( navigator . userAgent ) && ! this . TRIDENT ;
48
55
56
+ /** Whether the current browser is Safari. */
49
57
// Safari browsers will include the Safari keyword in their userAgent. Some browsers may fake
50
58
// this and just place the Safari keyword in the userAgent. To be more safe about Safari every
51
59
// Safari browser should also use Webkit as its layout engine.
52
- SAFARI = this . isBrowser && / s a f a r i / i. test ( navigator . userAgent ) && this . WEBKIT ;
60
+ SAFARI : boolean = this . isBrowser && / s a f a r i / i. test ( navigator . userAgent ) && this . WEBKIT ;
53
61
}
0 commit comments