馃悶 bug report
Affected Package
The issue is caused by package @angular/core
Is this a regression?
Yes, the previous version in which this bug was not present was: I don't know. The error is occurring with Ivy and not View Engine.
Description
I am working with dynamic views and decided to add an embeddedViewRef.detectChanges() call in my app which unexpectedly spit out the following error:
core.js:4197 ERROR TypeError: Cannot read property '5' of null at updateTransplantedViewCount (core.js:2425) at refreshView (core.js:7268) at detectChangesInternal (core.js:8506) at ViewRef.detectChanges (core.js:9864)
This error is occurring in the first line of the updateTransplantedViewCount function:
|
export function updateTransplantedViewCount(lContainer: LContainer, amount: 1|- 1) { |
|
lContainer[TRANSPLANTED_VIEWS_TO_REFRESH] += amount; |
due to the LContainer input variable being null.
And updateTransplantedViewCount is being called inside refreshView here:
|
if (lView[FLAGS] & LViewFlags.RefreshTransplantedView) { |
|
lView[FLAGS] &= ~LViewFlags.RefreshTransplantedView; |
|
updateTransplantedViewCount(lView[PARENT] as LContainer, -1); |
|
} |
|
} finally { |
|
leaveView(); |
|
} |
|
} |
...so lView[PARENT] here is resolving to null.
The obvious first reaction is "well, let's add a null check to one of these functions"...but I'm not familiar enough with the Ivy internals to know if lView[PARENT] being null alongside LViewFlags.RefreshTransplantedView being set represents some larger architecture issue (i.e. this scenario should be "impossible").
For a little more context, I am calling embeddedViewRef.detectChanges() on a non-destroyed embedded view ref that is not attached to a view container ref (was previously attached, but had been detached).
馃敩 Minimal Reproduction
Currently struggling to make a repro. If I can't get it to repro, then I'll upload a snapshot of my code.
馃實 Your Environment
Angular Version:
Angular CLI: 10.0.8
Node: 14.8.0
OS: win32 x64
Angular: 10.0.14
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.1000.8
@angular-devkit/build-angular 0.1000.8
@angular-devkit/build-ng-packagr 0.1000.8
@angular-devkit/build-optimizer 0.1000.8
@angular-devkit/build-webpack 0.1000.8
@angular-devkit/core 10.0.8
@angular-devkit/schematics 10.0.8
@angular/cli 10.0.8
@ngtools/webpack 10.0.8
@schematics/angular 10.0.8
@schematics/update 0.1000.8
ng-packagr 10.1.0
rxjs 6.5.5
typescript 3.9.7
webpack 4.43.0
馃悶 bug report
Affected Package
The issue is caused by package @angular/coreIs this a regression?
Yes, the previous version in which this bug was not present was: I don't know. The error is occurring with Ivy and not View Engine.Description
I am working with dynamic views and decided to add an
embeddedViewRef.detectChanges()call in my app which unexpectedly spit out the following error:core.js:4197 ERROR TypeError: Cannot read property '5' of null at updateTransplantedViewCount (core.js:2425) at refreshView (core.js:7268) at detectChangesInternal (core.js:8506) at ViewRef.detectChanges (core.js:9864)This error is occurring in the first line of the
updateTransplantedViewCountfunction:angular/packages/core/src/render3/util/view_utils.ts
Lines 198 to 199 in 90cec40
due to the
LContainerinput variable beingnull.And
updateTransplantedViewCountis being called insiderefreshViewhere:angular/packages/core/src/render3/instructions/shared.ts
Lines 520 to 527 in 90cec40
...so
lView[PARENT]here is resolving tonull.The obvious first reaction is "well, let's add a
nullcheck to one of these functions"...but I'm not familiar enough with the Ivy internals to know iflView[PARENT]being null alongsideLViewFlags.RefreshTransplantedViewbeing set represents some larger architecture issue (i.e. this scenario should be "impossible").For a little more context, I am calling
embeddedViewRef.detectChanges()on a non-destroyed embedded view ref that is not attached to a view container ref (was previously attached, but had been detached).馃敩 Minimal Reproduction
Currently struggling to make a repro. If I can't get it to repro, then I'll upload a snapshot of my code.馃實 Your Environment
Angular Version: