Fixed: Custom components within other custom components: occasionally not loaded "in time" and ignoring css

Resolves #1639
This commit is contained in:
Rossen Hristov
2016-12-12 16:45:36 +02:00
parent 624717a396
commit 8586eded36
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