Merge pull request #2745 from conficient/master

Valerie: added new interfaces; Knockout: fixed .register overloads
This commit is contained in:
Igor Oleinikov
2014-09-26 15:03:13 -07:00
4 changed files with 393 additions and 27 deletions
+45
View File
@@ -602,4 +602,49 @@ function test_allBindingsAccessor() {
var fnAccessorBinding = allBindingsAccessor().myBindingName;
}
};
}
function test_Components() {
function test_Register() {
// test all possible ko.components.register() overloads
var nodeArray = [new Node, new Node];
var singleNode = new Node;
// ------- string-templates with different viewmodel overloads:
// string template and inline function (commonly used in examples)
ko.components.register("name", { template: "string-template", viewModel: function (params) { return null; } });
// string template and instance vm
ko.components.register("name", { template: "string-template", viewModel: { instance: null } });
// string template and createViewModel factory method
ko.components.register("name", { template: "string-template", viewModel: { createViewModel: function (params: any, componentInfo: KnockoutComponentInfo) { return null; } } });
// string template and require module vm
ko.components.register("name", { template: "string-template", viewModel: { require: "module" } });
// ------- non-string templates
// viewmodel as function and four types of template
ko.components.register("name", { template: { element: "elementID" }, viewModel: function (params) { return null; } });
// Node template for element and inline function (commonly used in examples)
ko.components.register("name", { template: { element: singleNode }, viewModel: function (params) { return null; } });
// object template for element and inline function (commonly used in examples)
ko.components.register("name", { template: nodeArray, viewModel: function (params) { return null; } });
// object template for element and inline function (commonly used in examples)
ko.components.register("name", { template: { require: "module" }, viewModel: function (params) { return null; } });
// viewmodel as object, and four types of non-string tempalte
ko.components.register("name", { template: { element: "elementID" }, viewModel: { instance: null } });
// Node template for element and inline function (commonly used in examples)
ko.components.register("name", { template: { element: singleNode }, viewModel: { instance: null } });
// object template for element and inline function (commonly used in examples)
ko.components.register("name", { template: nodeArray, viewModel: { instance: null } });
// object template for element and inline function (commonly used in examples)
ko.components.register("name", { template: { require: "module" }, viewModel: { instance: null } });
//
}
}