Which @angular/* package(s) are the source of the bug?
platform-browser
Is this a regression?
Yes
Description
When running unit tests for a component that uses ViewEncapsulation.ShadowDom an error is thrown TypeError: Cannot destructure property 'elements' of 'this.registry' as it is undefined.. This was introduced in v20.2.0 and works in v20.1.8. In my case this seems to happen when calling fixture.detectChanges()
Upon investigation it looks like changes in dom_renderer.js are causing the issue. this.registry is defined as the return value of the function getAnimationElementRemovalRegistry - see here. This then causes an issue in the removeChild function, the following line doesn't work as this.registry isn't defined
const { elements } = this.registry;
see file here.
Seems to only be throwing the error specifically with ViewEncapsulation.ShadowDom set.
It occurs in version 20.2.0 and above
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
TypeError: Cannot destructure property 'elements' of 'this.registry' as it is undefined.
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 20.2.1
Node: 22.14.0
Package Manager: npm 10.9.2
OS: darwin arm64
Angular: 20.2.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser-dynamic, router
Package Version
---------------------------------------
@angular-devkit/architect 0.2002.1
@angular-devkit/build-angular 20.2.1
@angular-devkit/core 20.2.1
@angular-devkit/schematics 20.2.1
@angular/cli 20.2.1
@angular/platform-browser 20.2.0
@schematics/angular 20.2.1
ng-packagr 20.2.0
rxjs 7.8.2
typescript 5.8.3
zone.js 0.15.1
Anything else?
No response
Which @angular/* package(s) are the source of the bug?
platform-browser
Is this a regression?
Yes
Description
When running unit tests for a component that uses
ViewEncapsulation.ShadowDoman error is thrownTypeError: Cannot destructure property 'elements' of 'this.registry' as it is undefined.. This was introduced in v20.2.0 and works in v20.1.8. In my case this seems to happen when callingfixture.detectChanges()Upon investigation it looks like changes in
dom_renderer.jsare causing the issue.this.registryis defined as the return value of the functiongetAnimationElementRemovalRegistry- see here. This then causes an issue in theremoveChildfunction, the following line doesn't work asthis.registryisn't definedsee file here.
Seems to only be throwing the error specifically with
ViewEncapsulation.ShadowDomset.It occurs in version 20.2.0 and above
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version)Anything else?
No response