|
6 | 6 | * found in the LICENSE file at https://angular.dev/license
|
7 | 7 | */
|
8 | 8 |
|
9 |
| -import {Component, destroyPlatform, ErrorHandler, PLATFORM_ID, Type} from '@angular/core'; |
| 9 | +import {APP_ID, Component, destroyPlatform, ErrorHandler, PLATFORM_ID, Type} from '@angular/core'; |
10 | 10 | import {
|
11 | 11 | withEventReplay,
|
12 | 12 | bootstrapApplication,
|
@@ -142,6 +142,40 @@ describe('event replay', () => {
|
142 | 142 | expect(onClickSpy).toHaveBeenCalled();
|
143 | 143 | });
|
144 | 144 |
|
| 145 | + it('should cleanup `window._ejsas[appId]` once app is destroyed', async () => { |
| 146 | + @Component({ |
| 147 | + selector: 'app', |
| 148 | + standalone: true, |
| 149 | + template: ` |
| 150 | + <button id="btn" (click)="onClick()"></button> |
| 151 | + `, |
| 152 | + }) |
| 153 | + class AppComponent { |
| 154 | + onClick() {} |
| 155 | + } |
| 156 | + |
| 157 | + const html = await ssr(AppComponent); |
| 158 | + const ssrContents = getAppContents(html); |
| 159 | + const doc = getDocument(); |
| 160 | + |
| 161 | + prepareEnvironment(doc, ssrContents); |
| 162 | + resetTViewsFor(AppComponent); |
| 163 | + |
| 164 | + const btn = doc.getElementById('btn')!; |
| 165 | + btn.click(); |
| 166 | + |
| 167 | + const appRef = await hydrate(doc, AppComponent, { |
| 168 | + hydrationFeatures: () => [withEventReplay()], |
| 169 | + }); |
| 170 | + appRef.tick(); |
| 171 | + const appId = appRef.injector.get(APP_ID); |
| 172 | + |
| 173 | + appRef.destroy(); |
| 174 | + // This ensure that `_ejsas` for the current application is cleaned up |
| 175 | + // once the application is destroyed. |
| 176 | + expect(window._ejsas![appId]).toBeUndefined(); |
| 177 | + }); |
| 178 | + |
145 | 179 | it('should route to the appropriate component with content projection', async () => {
|
146 | 180 | const outerOnClickSpy = jasmine.createSpy();
|
147 | 181 | const innerOnClickSpy = jasmine.createSpy();
|
|
0 commit comments