BindingContext set two times on adding item to ListView. Fixes issue #410.

This commit is contained in:
Nedyalko Nikolov
2015-07-14 14:47:40 +03:00
parent feadf177de
commit b45718b1ef
4 changed files with 40 additions and 4 deletions

View File

@@ -580,6 +580,33 @@ export function test_bindingToParentObjectWithSpacesInIndexer() {
helper.buildUIAndRunTest(listView, testAction);
}
export function test_ConverterIsCalledJustOnce_onAddingItemsToListView() {
var listView = new listViewModule.ListView();
var converterCalledCounter = 0;
var testConverter = function (value) {
converterCalledCounter++;
return value;
}
app.resources["testConverter"] = testConverter;
function testAction(views: Array<viewModule.View>) {
var listViewModel = new observable.Observable();
listViewModel.set("items", [1, 2, 3]);
listView.bindingContext = listViewModel;
listView.bind({ sourceProperty: "items", targetProperty: "items" });
listView.itemTemplate = "<Label id=\"testLabel\" text=\"{{ $value, $value | testConverter }}\" />";
TKUnit.wait(ASYNC);
TKUnit.assertEqual(converterCalledCounter, listViewModel.get("items").length, "Converter should be called once for every item.");
}
helper.buildUIAndRunTest(listView, testAction);
}
export function test_no_memory_leak_when_items_is_regular_array() {
var createFunc = function (): listViewModule.ListView {
var listView = new listViewModule.ListView();