diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index 9c4e02bd8..71252985d 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -123,9 +123,14 @@ interface KnockoutBindingContext { createChildContext(dataItemOrAccessor: any, dataItemAlias?: any, extendCallback?: Function): any; } +interface KnockoutAllBindingsAccessor { + (): any; + get(bindingName: string): any; +} + interface KnockoutBindingHandler { - init?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void; - update?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void; + init?(element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void; + update?(element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void; options?: any; } diff --git a/knockout/tests/knockout-tests.ts b/knockout/tests/knockout-tests.ts index 1ebef13ef..da5d1e65a 100644 --- a/knockout/tests/knockout-tests.ts +++ b/knockout/tests/knockout-tests.ts @@ -581,4 +581,21 @@ function test_misc() { } } +} + +interface KnockoutBindingHandlers { + allBindingsAccessorTest: KnockoutBindingHandler; +} + +function test_allBindingsAccessor() { + ko.bindingHandlers.allBindingsAccessorTest = { + init: (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext) => { + var allBindings = allBindingsAccessor(); + var myBinding = allBindingsAccessor.get("myBindingName"); + }, + update: (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext) => { + var allBindings = allBindingsAccessor(); + var myBinding = allBindingsAccessor.get("myBindingName"); + } + }; } \ No newline at end of file