Merge pull request #3285 from NativeScript/issue-1639

Fix: Custom components within other custom components: occasionally…
This commit is contained in:
Rossen Hristov
2017-01-03 10:24:12 +02:00
committed by GitHub
10 changed files with 43 additions and 10 deletions

View File

@@ -63,6 +63,12 @@ function parseInternal(value: string, context: any, uri?: string): ComponentModu
}
function loadCustomComponent(componentPath: string, componentName?: string, attributes?: Object, context?: Object, parentPage?: Page): ComponentModule {
if (!parentPage && context){
// Read the parent page that was passed down below
// https://github.com/NativeScript/NativeScript/issues/1639
parentPage = context["_parentPage"];
delete context["_parentPage"];
}
var result: ComponentModule;
componentPath = componentPath.replace("~/", "");
const moduleName = componentPath + "/" + componentName;
@@ -90,6 +96,13 @@ function loadCustomComponent(componentPath: string, componentName?: string, attr
}
}
// Pass the parent page down the chain in case of custom components nested on many levels. Use the context for piggybacking.
// https://github.com/NativeScript/NativeScript/issues/1639
if (!subExports) {
subExports = {};
}
subExports["_parentPage"] = parentPage;
result = loadInternal(xmlFilePath, subExports);
// Attributes will be transfered to the custom component