mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
Fixed issue with updating nested properties via binding.
This commit is contained in:
@ -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);
|
||||||
|
}
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user