Fixed getting object properties too many times.

This commit is contained in:
Nedyalko Nikolov
2015-12-16 11:14:16 +02:00
parent 04b13beb04
commit 5e440ab924
2 changed files with 32 additions and 2 deletions

View File

@@ -908,4 +908,33 @@ export var test_BindingContextOfAChildElementIsNotOverwrittenBySettingTheBinding
TKUnit.waitUntilReady(() => { return testFinished });
helper.goBack();
done(null);
}
}
export var test_BindingHitsGetterTooManyTimes = function () {
var counter = 0;
class Dummy extends observable.Observable {
private _dummyProperty: string;
public get dummyProperty(): string {
counter++;
return this._dummyProperty;
}
public set dummyProperty(value: string) {
if (this._dummyProperty !== value) {
this._dummyProperty = value;
this.notifyPropertyChange("dummyProperty", value);
}
}
}
var model = new Dummy();
model.dummyProperty = "OPA";
var bindableObj = new bindable.Bindable();
bindableObj.bind({ sourceProperty: "dummyProperty", targetProperty: "dummyTarget" }, model);
TKUnit.assertEqual(counter, 1, "Property getter should be hit only once!");
}