From a35cc27781ebc696240c4310654605f8c2de3eb7 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Tue, 17 Mar 2015 19:37:41 +0100 Subject: [PATCH] fix(PropertyBindingParser): properly parse event bindings as actions Fixes #981 Closes #987 --- .../core/compiler/pipeline/property_binding_parser.js | 2 +- .../compiler/pipeline/property_binding_parser_spec.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/angular2/src/core/compiler/pipeline/property_binding_parser.js b/modules/angular2/src/core/compiler/pipeline/property_binding_parser.js index 8e28cff2f7..3914ab335f 100644 --- a/modules/angular2/src/core/compiler/pipeline/property_binding_parser.js +++ b/modules/angular2/src/core/compiler/pipeline/property_binding_parser.js @@ -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); diff --git a/modules/angular2/test/core/compiler/pipeline/property_binding_parser_spec.js b/modules/angular2/test/core/compiler/pipeline/property_binding_parser_spec.js index f74ec0707a..7a9d8f78c5 100644 --- a/modules/angular2/test/core/compiler/pipeline/property_binding_parser_spec.js +++ b/modules/angular2/test/core/compiler/pipeline/property_binding_parser_spec.js @@ -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('
')); expect(MapWrapper.get(results[0].eventBindings, 'click[]').source).toEqual('b()'); + }); + it('should parse event handlers using () syntax as actions', () => { + var results = createPipeline().process(el('
')); + expect(MapWrapper.get(results[0].eventBindings, 'click').source).toEqual('foo=bar'); }); it('should detect on- syntax', () => { var results = createPipeline().process(el('
')); 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('
')); + expect(MapWrapper.get(results[0].eventBindings, 'click').source).toEqual('foo=bar'); + }); }); }