Skip to content

Commit

Permalink
Merge pull request DefinitelyTyped#2393 from bolhovsky/custom-bindings
Browse files Browse the repository at this point in the history
Extend custom bindings API definition
  • Loading branch information
vvakame committed Jul 10, 2014
2 parents a87641d + d1db936 commit 20e2817
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions knockout/knockout.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,13 @@ interface KnockoutBindingContext {

interface KnockoutAllBindingsAccessor {
(): any;
get(bindingName: string): any;
get(name: string): any;
has(name: string): boolean;
}

interface KnockoutBindingHandler {
init?(element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void;
update?(element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, 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;
}

Expand Down
4 changes: 4 additions & 0 deletions knockout/tests/knockout-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,15 @@ function test_allBindingsAccessor() {
ko.bindingHandlers.allBindingsAccessorTest = {
init: (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext) => {
var allBindings = allBindingsAccessor();
var hasBinding = allBindingsAccessor.has("myBindingName");
var myBinding = allBindingsAccessor.get("myBindingName");
var fnAccessorBinding = allBindingsAccessor().myBindingName;
},
update: (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext) => {
var allBindings = allBindingsAccessor();
var hasBinding = allBindingsAccessor.has("myBindingName");
var myBinding = allBindingsAccessor.get("myBindingName");
var fnAccessorBinding = allBindingsAccessor().myBindingName;
}
};
}

0 comments on commit 20e2817

Please sign in to comment.