From 9460133e0a075af28fdeebaa5fe73d9e0fe69f8b Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 3 Sep 2018 16:45:39 +0200 Subject: [PATCH] MOBILE-2567 siteplugins: Fix error if initResult not defined --- src/core/siteplugins/providers/siteplugins.ts | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/core/siteplugins/providers/siteplugins.ts b/src/core/siteplugins/providers/siteplugins.ts index 2dab2bbf2..d8d5a4ab1 100644 --- a/src/core/siteplugins/providers/siteplugins.ts +++ b/src/core/siteplugins/providers/siteplugins.ts @@ -149,15 +149,19 @@ export class CoreSitePluginsProvider { * @return {any} An object with the data to pass to the JS. */ createDataForJS(initResult: any, contentResult?: any): any { - // First of all, add the data returned by the init JS (if any). - let data = this.utils.clone(initResult.jsResult || {}); - if (typeof data == 'boolean') { - data = {}; - } + let data; - // Now add some data returned by the init WS call. - data.INIT_TEMPLATES = this.utils.objectToKeyValueMap(initResult.templates, 'id', 'html'); - data.INIT_OTHERDATA = initResult.otherdata; + if (initResult) { + // First of all, add the data returned by the init JS (if any). + data = this.utils.clone(initResult.jsResult || {}); + if (typeof data == 'boolean') { + data = {}; + } + + // Now add some data returned by the init WS call. + data.INIT_TEMPLATES = this.utils.objectToKeyValueMap(initResult.templates, 'id', 'html'); + data.INIT_OTHERDATA = initResult.otherdata; + } if (contentResult) { // Now add the data returned by the content WS call.