Tests and fix for loading custom components with no code-behind

This commit is contained in:
vakrilov
2015-05-05 18:37:43 +03:00
parent a9a48ae781
commit 9eb0716562
4 changed files with 61 additions and 23 deletions

View File

@@ -103,8 +103,11 @@ export function getComponentModule(elementName: string, namespace: string, attri
}
export function setPropertyValue(instance: view.View, instanceModule: Object, exports: Object, propertyName: string, propertyValue: string) {
// Note: instanceModule can be null if we are loading custom compnenet with no code-behind.
var isEvent: boolean = instanceModule && isKnownEvent(propertyName, instanceModule[instance.typeName]);
if (isBinding(propertyValue) && instance.bind) {
if (isKnownEvent(propertyName, instanceModule[instance.typeName])) {
if (isEvent) {
attachEventBinding(instance, propertyName, propertyValue);
} else {
var bindOptions = bindingBuilder.getBindingOptions(propertyName, getBindingExpressionFromAttribute(propertyValue));
@@ -115,7 +118,7 @@ export function setPropertyValue(instance: view.View, instanceModule: Object, ex
twoWay: bindOptions[bindingBuilder.bindingConstants.twoWay]
}, bindOptions[bindingBuilder.bindingConstants.source]);
}
} else if (isKnownEvent(propertyName, instanceModule[instance.typeName])) {
} else if (isEvent) {
// Get the event handler from page module exports.
var handler = exports && exports[propertyValue];