fix(ivy): init hooks being re-run if an exception is throw (#28024)

Fixes Ivy running the init hooks if an exception is thrown in one of them.

These changes fix FW-830.

PR Close #28024
This commit is contained in:
Kristiyan Kostadinov 2019-01-09 21:28:38 +01:00 committed by Andrew Kushnir
parent 3bafc002ae
commit a6ba789599
2 changed files with 30 additions and 29 deletions

View File

@ -319,11 +319,14 @@ export function leaveView(newView: LView): void {
if (isCreationMode(lView)) {
lView[FLAGS] &= ~LViewFlags.CreationMode;
} else {
try {
executeHooks(lView, tView.viewHooks, tView.viewCheckHooks, checkNoChangesMode);
} finally {
// Views are clean and in update mode after being checked, so these bits are cleared
lView[FLAGS] &= ~(LViewFlags.Dirty | LViewFlags.FirstLViewPass);
lView[FLAGS] |= LViewFlags.RunInit;
lView[BINDING_INDEX] = tView.bindingStartIndex;
}
}
enterView(newView, null);
}

View File

@ -1022,11 +1022,9 @@ const TEST_COMPILER_PROVIDERS: Provider[] = [
expect(directiveLog.filter(['ngAfterViewInit'])).toEqual([]);
}));
fixmeIvy(
'FW-830: Exception thrown in ngAfterViewInit triggers ngAfterViewInit re-execution')
.it('should not call ngAfterViewInit again if it throws', fakeAsync(() => {
const ctx = createCompFixture(
'<div testDirective="dir" throwOn="ngAfterViewInit"></div>');
it('should not call ngAfterViewInit again if it throws', fakeAsync(() => {
const ctx =
createCompFixture('<div testDirective="dir" throwOn="ngAfterViewInit"></div>');
let errored = false;
// First pass fails, but ngAfterViewInit should be called.