fix(ivy): component destroy hook called twice when configured as provider (#28470)

Fixes the `ngOnDestroy` hook on a component or directive being called twice, if the type is also registered as a provider.

This PR resolves FW-1010.

PR Close #28470
This commit is contained in:
Kristiyan Kostadinov
2019-01-31 10:38:43 +01:00
committed by Igor Minar
parent 0ea216b993
commit e1aaa7ec48
12 changed files with 285 additions and 75 deletions

View File

@ -520,10 +520,6 @@ export function getNodeInjectable(
setTNodeAndViewData(tNode, lData);
try {
value = lData[index] = factory.factory(null, tData, lData, tNode);
const tView = lData[TVIEW];
if (value && factory.isProvider && value.ngOnDestroy) {
(tView.destroyHooks || (tView.destroyHooks = [])).push(index, value.ngOnDestroy);
}
} finally {
if (factory.injectImpl) setInjectImplementation(previousInjectImplementation);
setIncludeViewProviders(previousIncludeViewProviders);