Skip to content

Commit

Permalink
feat(templating): add property name to bindable info
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Jul 3, 2018
1 parent 16f02be commit a9e715c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/runtime/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function hyphenate(name) {
* Decorator: Specifies custom behavior for a bindable property.
* @param configOrTarget The overrides.
*/
export function bindable(configOrTarget?: IBindableInstruction | Object, key?, descriptor?): any {
export function bindable(configOrTarget?: Omit<IBindableInstruction, 'property'> | Object, key?, descriptor?): any {
let deco = function(target, key2, descriptor2) {
target = target.constructor;

Expand All @@ -121,6 +121,7 @@ export function bindable(configOrTarget?: IBindableInstruction | Object, key?, d
config.mode = BindingMode.oneWay;
}

config.property = key2;
bindables[key2] = config;
};

Expand Down
1 change: 1 addition & 0 deletions src/runtime/templating/instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface IBindableInstruction {
mode?: BindingMode;
callback?: string;
attribute?: string;
property?: string;
}

export type TemplateDefinition = Immutable<Required<ITemplateSource>>;
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/templating/rendering-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ class RuntimeCompilationResources implements ICompilationResources {
return this.getDescription<IAttributeDescription>(Resource.attribute.key(attributeName));
}

private getDescription<T extends (IElementDescription | IAttributeDescription)>(name: string) {
const resolver = this.context.getResolver(name);
private getDescription<T extends (IElementDescription | IAttributeDescription)>(key: string) {
const resolver = this.context.getResolver(key);

if (resolver !== null && resolver.getFactory) {
let factory = resolver.getFactory(this.context);
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/templating/runtime-behavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class RuntimeBehavior implements IRuntimeBehavior {
const callback = `${name}Changed`;

if (callback in instance) {
bindables[name] = { callback };
bindables[name] = { callback, property: name };
}
}

Expand Down

0 comments on commit a9e715c

Please sign in to comment.