fix(ivy): ensure animation component host listeners are rendered in the sub component (#28210)

Due to the fact that animations in Angular are defined in the component metadata,
all animation trigger definitions are localized to the component and are
inaccessible outside of it. Animation host listeners in Ivy are
rendered in the context of the parent component, but the VE renders them
differently. This patch ensures that animation host listeners are
always registered in the sub component's renderer

Jira issue: FW-943
Jira issue: FW-958

PR Close #28210
This commit is contained in:
Matias Niemelä
2019-01-17 11:09:13 -08:00
committed by Alex Rickabaugh
parent c1c87462fd
commit 6940992932
9 changed files with 119 additions and 74 deletions

View File

@ -34,6 +34,9 @@ export class Identifiers {
static componentHostSyntheticProperty:
o.ExternalReference = {name: 'ɵcomponentHostSyntheticProperty', moduleName: CORE};
static componentHostSyntheticListener:
o.ExternalReference = {name: 'ɵcomponentHostSyntheticListener', moduleName: CORE};
static elementAttribute: o.ExternalReference = {name: 'ɵelementAttribute', moduleName: CORE};
static elementClassProp: o.ExternalReference = {name: 'ɵelementClassProp', moduleName: CORE};

View File

@ -839,7 +839,9 @@ function createHostListeners(
meta.name && bindingName ? `${meta.name}_${bindingFnName}_HostBindingHandler` : null;
const params = prepareEventListenerParameters(
BoundEvent.fromParsedEvent(binding), bindingContext, handlerName);
return o.importExpr(R3.listener).callFn(params).toStmt();
const instruction =
binding.type == ParsedEventType.Animation ? R3.componentHostSyntheticListener : R3.listener;
return o.importExpr(instruction).callFn(params).toStmt();
});
}