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[] {