fix(PropertyBindingParser): properly parse event bindings as actions

Fixes #981

Closes #987
This commit is contained in:
Pawel Kozlowski 2015-03-17 19:37:41 +01:00
parent 6cdbe4a264
commit a35cc27781
2 changed files with 10 additions and 1 deletions

View File

@ -66,7 +66,7 @@ export class PropertyBindingParser extends CompileStep {
MapWrapper.set(newAttrs, bindParts[5], attrValue);
} else if (isPresent(bindParts[6])) {
// match: (event)
current.addEventBinding(bindParts[6], this._parseBinding(attrValue, desc));
current.addEventBinding(bindParts[6], this._parseAction(attrValue, desc));
}
} else {
var ast = this._parseInterpolation(attrValue, desc);

View File

@ -68,13 +68,22 @@ export function main() {
// "(click[])" is not an expected syntax and is only used to validate the regexp
results = createPipeline().process(el('<div (click[])="b()"></div>'));
expect(MapWrapper.get(results[0].eventBindings, 'click[]').source).toEqual('b()');
});
it('should parse event handlers using () syntax as actions', () => {
var results = createPipeline().process(el('<div (click)="foo=bar"></div>'));
expect(MapWrapper.get(results[0].eventBindings, 'click').source).toEqual('foo=bar');
});
it('should detect on- syntax', () => {
var results = createPipeline().process(el('<div on-click="b()"></div>'));
expect(MapWrapper.get(results[0].eventBindings, 'click').source).toEqual('b()');
});
it('should parse event handlers using on- syntax as actions', () => {
var results = createPipeline().process(el('<div on-click="foo=bar"></div>'));
expect(MapWrapper.get(results[0].eventBindings, 'click').source).toEqual('foo=bar');
});
});
}