mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge pull request #150 from NativeScript/nnikolov/BindingWithSourceIssue
Fixed issue when UI element is bound to source different from binding…
This commit is contained in:
@@ -491,3 +491,25 @@ export var test_BindingContext_NavigatingForwardAndBack = function () {
|
|||||||
|
|
||||||
helper.navigateToModuleAndRunTest("./tests/ui/bindingContext_testPage1", null, testFunc);
|
helper.navigateToModuleAndRunTest("./tests/ui/bindingContext_testPage1", null, testFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export var test_BindingToSource_FailsAfterBindingContextChange = function () {
|
||||||
|
var createLabel = function () {
|
||||||
|
var label = new labelModule.Label();
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
var labelViewModel = new observable.Observable();
|
||||||
|
var expectedValue = "testValue";
|
||||||
|
labelViewModel.set("testProperty", expectedValue);
|
||||||
|
|
||||||
|
var testFunc = function (views: Array<viewModule.View>) {
|
||||||
|
var testLabel = <labelModule.Label>(views[0]);
|
||||||
|
testLabel.bind({ sourceProperty: "testProperty", targetProperty: "text" }, labelViewModel);
|
||||||
|
|
||||||
|
var page = <pageModule.Page>(views[1]);
|
||||||
|
page.bindingContext = new observable.Observable;
|
||||||
|
|
||||||
|
TKUnit.assertEqual(testLabel.text, expectedValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.buildUIAndRunTest(createLabel(), testFunc);
|
||||||
|
}
|
||||||
@@ -102,7 +102,8 @@ export class Bindable extends dependencyObservable.DependencyObservable implemen
|
|||||||
for (var p in this._bindings) {
|
for (var p in this._bindings) {
|
||||||
binding = this._bindings[p];
|
binding = this._bindings[p];
|
||||||
|
|
||||||
if (binding.updating) {
|
var sourceIsNotBindingContext = (binding.source && (binding.source.get() !== oldValue));
|
||||||
|
if (binding.updating || sourceIsNotBindingContext) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user