fix(compiler): explicitly support event bindings also on <template>
elements
Although these events don’t fire events themselves, there might be directives on them that fire events. Closes #4712
This commit is contained in:
@ -800,7 +800,7 @@ export function main() {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should support events via EventEmitter',
|
||||
it('should support events via EventEmitter on regular elements',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<div emitter listener></div>',
|
||||
@ -825,6 +825,31 @@ export function main() {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should support events via EventEmitter on template elements',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<template emitter listener></template>',
|
||||
directives: [DirectiveEmitingEvent, DirectiveListeningEvent]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
|
||||
var tc = rootTC.debugElement.componentViewChildren[0];
|
||||
var emitter = tc.inject(DirectiveEmitingEvent);
|
||||
var listener = tc.inject(DirectiveListeningEvent);
|
||||
|
||||
expect(listener.msg).toEqual('');
|
||||
|
||||
ObservableWrapper.subscribe(emitter.event, (_) => {
|
||||
expect(listener.msg).toEqual('fired !');
|
||||
async.done();
|
||||
});
|
||||
|
||||
emitter.fireEvent('fired !');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should support [()] syntax',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
|
Reference in New Issue
Block a user