mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fixed: The Repeater is re-creating its children multiple times during initialization. #873
This commit is contained in:
@@ -3,6 +3,7 @@ import app = require("application");
|
||||
import helper = require("../helper");
|
||||
import viewModule = require("ui/core/view");
|
||||
import stackLayoutModule = require("ui/layouts/stack-layout");
|
||||
import wrapLayoutModule = require("ui/layouts/wrap-layout");
|
||||
import layoutBaseModule = require("ui/layouts/layout-base");
|
||||
import fs = require("file-system");
|
||||
import pageModule = require("ui/page");
|
||||
@@ -180,7 +181,7 @@ export function test_set_itmes_to_null_clears_items() {
|
||||
helper.buildUIAndRunTest(repeater, testAction);
|
||||
}
|
||||
|
||||
export function test_set_itmeLayout_accepted() {
|
||||
export function test_set_itemsLayout_accepted() {
|
||||
// <snippet module="ui/repeater" title="repeater">
|
||||
// ### Using Repeater with different layout.
|
||||
// ``` JavaScript
|
||||
@@ -434,6 +435,26 @@ export var test_RepeaterItemsParentBindingsShouldWork = function () {
|
||||
helper.navigateToModuleAndRunTest(("." + moduleName + "/repeaterItems-bindingToGestures"), null, testFunc);
|
||||
}
|
||||
|
||||
export function test_ChildrenAreNotCreatedUntilTheRepeaterIsLoaded() {
|
||||
var repeater = new repeaterModule.Repeater();
|
||||
|
||||
repeater.itemsLayout = new wrapLayoutModule.WrapLayout();
|
||||
TKUnit.assertEqual(getChildrenCount(repeater), 0, "Repeater should not create its children until loaded.");
|
||||
|
||||
repeater.itemTemplate = "<Label id=\"testLabel\" text=\"{{ $value, $value + ' some static text' }}\" />";
|
||||
TKUnit.assertEqual(getChildrenCount(repeater), 0, "Repeater should not create its children until loaded.");
|
||||
|
||||
repeater.items = [1, 2, 3];
|
||||
TKUnit.assertEqual(getChildrenCount(repeater), 0, "Repeater should not create its children until loaded.");
|
||||
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
TKUnit.waitUntilReady(() => repeater.isLoaded);
|
||||
TKUnit.assertEqual(getChildrenCount(repeater), 3, "Repeater should have created its children when loaded.");
|
||||
}
|
||||
|
||||
helper.buildUIAndRunTest(repeater, testAction);
|
||||
}
|
||||
|
||||
/*
|
||||
export function test_no_memory_leak_when_items_is_regular_array() {
|
||||
var createFunc = function (): repeaterModule.Repeater {
|
||||
|
||||
Reference in New Issue
Block a user