fix(PropertyBindingParser): properly parse event bindings as actions
Fixes #981 Closes #987
This commit is contained in:
parent
6cdbe4a264
commit
a35cc27781
|
@ -66,7 +66,7 @@ export class PropertyBindingParser extends CompileStep {
|
||||||
MapWrapper.set(newAttrs, bindParts[5], attrValue);
|
MapWrapper.set(newAttrs, bindParts[5], attrValue);
|
||||||
} else if (isPresent(bindParts[6])) {
|
} else if (isPresent(bindParts[6])) {
|
||||||
// match: (event)
|
// match: (event)
|
||||||
current.addEventBinding(bindParts[6], this._parseBinding(attrValue, desc));
|
current.addEventBinding(bindParts[6], this._parseAction(attrValue, desc));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var ast = this._parseInterpolation(attrValue, desc);
|
var ast = this._parseInterpolation(attrValue, desc);
|
||||||
|
|
|
@ -68,13 +68,22 @@ export function main() {
|
||||||
// "(click[])" is not an expected syntax and is only used to validate the regexp
|
// "(click[])" is not an expected syntax and is only used to validate the regexp
|
||||||
results = createPipeline().process(el('<div (click[])="b()"></div>'));
|
results = createPipeline().process(el('<div (click[])="b()"></div>'));
|
||||||
expect(MapWrapper.get(results[0].eventBindings, 'click[]').source).toEqual('b()');
|
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', () => {
|
it('should detect on- syntax', () => {
|
||||||
var results = createPipeline().process(el('<div on-click="b()"></div>'));
|
var results = createPipeline().process(el('<div on-click="b()"></div>'));
|
||||||
expect(MapWrapper.get(results[0].eventBindings, 'click').source).toEqual('b()');
|
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');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue