Skip to content

Commit a35cc27

Browse files
fix(PropertyBindingParser): properly parse event bindings as actions
Fixes angular#981 Closes angular#987
1 parent 6cdbe4a commit a35cc27

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

modules/angular2/src/core/compiler/pipeline/property_binding_parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class PropertyBindingParser extends CompileStep {
6666
MapWrapper.set(newAttrs, bindParts[5], attrValue);
6767
} else if (isPresent(bindParts[6])) {
6868
// match: (event)
69-
current.addEventBinding(bindParts[6], this._parseBinding(attrValue, desc));
69+
current.addEventBinding(bindParts[6], this._parseAction(attrValue, desc));
7070
}
7171
} else {
7272
var ast = this._parseInterpolation(attrValue, desc);

modules/angular2/test/core/compiler/pipeline/property_binding_parser_spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,22 @@ export function main() {
6868
// "(click[])" is not an expected syntax and is only used to validate the regexp
6969
results = createPipeline().process(el('<div (click[])="b()"></div>'));
7070
expect(MapWrapper.get(results[0].eventBindings, 'click[]').source).toEqual('b()');
71+
});
7172

73+
it('should parse event handlers using () syntax as actions', () => {
74+
var results = createPipeline().process(el('<div (click)="foo=bar"></div>'));
75+
expect(MapWrapper.get(results[0].eventBindings, 'click').source).toEqual('foo=bar');
7276
});
7377

7478
it('should detect on- syntax', () => {
7579
var results = createPipeline().process(el('<div on-click="b()"></div>'));
7680
expect(MapWrapper.get(results[0].eventBindings, 'click').source).toEqual('b()');
7781
});
82+
83+
it('should parse event handlers using on- syntax as actions', () => {
84+
var results = createPipeline().process(el('<div on-click="foo=bar"></div>'));
85+
expect(MapWrapper.get(results[0].eventBindings, 'click').source).toEqual('foo=bar');
86+
});
7887
});
7988
}
8089

0 commit comments

Comments
 (0)