Fixed issue with updating nested properties via binding.

This commit is contained in:
Nedyalko Nikolov
2015-06-08 09:27:59 +03:00
parent fd85e47fb1
commit a122d854d0
2 changed files with 33 additions and 1 deletions

View File

@ -542,3 +542,35 @@ export function test_BindingToDictionaryAtAppLevel() {
helper.buildUIAndRunTest(createLabel(), testFunc); helper.buildUIAndRunTest(createLabel(), testFunc);
} }
export function test_UpdatingNestedPropertyViaBinding() {
var expectedValue1 = "Alabala";
var expectedValue2 = "Tralala";
var viewModel = new observable.Observable();
var parentViewModel = new observable.Observable();
viewModel.set("parentView", parentViewModel);
parentViewModel.set("name", expectedValue1);
var testElement: bindable.Bindable = new bindable.Bindable();
testElement.bind({
sourceProperty: "parentView.name",
targetProperty: "targetName",
twoWay: true
}, viewModel);
var testElement2: bindable.Bindable = new bindable.Bindable();
testElement2.bind({
sourceProperty: "parentView.name",
targetProperty: "targetProperty",
twoWay: true
}, viewModel);
TKUnit.assertEqual(testElement.get("targetName"), expectedValue1);
testElement.set("targetName", expectedValue2);
TKUnit.assertEqual(parentViewModel.get("name"), expectedValue2);
TKUnit.assertEqual(testElement2.get("targetProperty"), expectedValue2);
}

View File

@ -261,7 +261,7 @@ export class Binding {
else { else {
this.updateTarget(expressionValue); this.updateTarget(expressionValue);
} }
} else if (data.propertyName === this.options.sourceProperty) { } else if (data.propertyName === this.sourceOptions.property) {
this.updateTarget(data.value); this.updateTarget(data.value);
} }
} }