mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
getExports moved to builder
This commit is contained in:
@ -10,6 +10,11 @@ var KNOWNCOLLECTIONS = "knownCollections";
|
||||
|
||||
export function parse(value: string, exports: any): view.View {
|
||||
var viewToReturn: view.View;
|
||||
|
||||
if (exports instanceof view.View) {
|
||||
exports = getExports(exports);
|
||||
}
|
||||
|
||||
var componentModule = parseInternal(value, exports);
|
||||
|
||||
if (componentModule) {
|
||||
@ -150,7 +155,7 @@ function parseInternal(value: string, exports: any): componentBuilder.ComponentM
|
||||
}
|
||||
}
|
||||
|
||||
}, (e) => {
|
||||
},(e) => {
|
||||
throw new Error("XML parse error: " + e.message);
|
||||
}, true);
|
||||
|
||||
@ -184,7 +189,7 @@ function loadInternal(fileName: string, exports: any): componentBuilder.Componen
|
||||
// Read the XML file.
|
||||
fileAccess.readText(fileName, result => {
|
||||
componentModule = parseInternal(result, exports);
|
||||
}, (e) => {
|
||||
},(e) => {
|
||||
throw new Error("Error loading file " + fileName + " :" + e.message);
|
||||
});
|
||||
}
|
||||
@ -234,3 +239,13 @@ interface ComplexProperty {
|
||||
name: string;
|
||||
items?: Array<any>;
|
||||
}
|
||||
|
||||
function getExports(instance: view.View): any {
|
||||
var parent = instance.parent;
|
||||
|
||||
while (parent && (<any>parent).exports === undefined) {
|
||||
parent = parent.parent;
|
||||
}
|
||||
|
||||
return parent ? (<any>parent).exports : undefined;
|
||||
}
|
Reference in New Issue
Block a user