Skip to content

Bug in DOM renderer (v20.2.0) causes tests to fail when component uses ViewEncapsulation.ShadowDom #63551

Description

@jtuds

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtimecore: animationsIssues related to `animate.enter` and `animate.leave`needs reproductionThis issue needs a reproduction in order for the team to investigate further

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions