From 82f9fd4ce786aafc43d19ea95a369bd94d06c995 Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Wed, 29 Aug 2018 01:23:31 +0200 Subject: [PATCH] fix(angular): platform does not crash fixes #15348 --- core/src/utils/platform.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/utils/platform.ts b/core/src/utils/platform.ts index 977acb1707..d2c19f7ec0 100644 --- a/core/src/utils/platform.ts +++ b/core/src/utils/platform.ts @@ -18,7 +18,7 @@ export const PLATFORMS_MAP = { export type Platforms = keyof typeof PLATFORMS_MAP; export function getPlatforms(win: any) { - return win.Ionic.platforms; + return setupPlatforms(win); } export function isPlatform(win: Window, platform: Platforms) { @@ -26,12 +26,15 @@ export function isPlatform(win: Window, platform: Platforms) { } export function setupPlatforms(win: any) { + win.Ionic = win.Ionic || {}; + let platforms: string[] = win.Ionic.platforms; if (platforms == null) { platforms = win.Ionic.platforms = detectPlatforms(win); const classList = win.document.documentElement.classList; platforms.forEach(p => classList.add(`plt-${p}`)); } + return platforms; } function detectPlatforms(win: Window): string[] {