Skip to content

Commit 3a7e82b

Browse files
committed
refactor: properly declare platform ID dependency in default view adapter as optional
1 parent da8cc10 commit 3a7e82b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/view-adapter/default.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ describe(NgrxDefaultViewAdapter.name, () => {
194194
});
195195

196196
it('should not throw if calling callbacks before they are registered', () => {
197-
expect(() => new NgrxDefaultViewAdapter(undefined as any, undefined as any, undefined as any).onChange(undefined)).not.toThrowError();
198-
expect(() => new NgrxDefaultViewAdapter(undefined as any, undefined as any, undefined as any).onTouched()).not.toThrowError();
197+
expect(() => new NgrxDefaultViewAdapter(undefined as any, undefined as any).onChange(undefined)).not.toThrowError();
198+
expect(() => new NgrxDefaultViewAdapter(undefined as any, undefined as any).onTouched()).not.toThrowError();
199199
});
200200
});

src/view-adapter/default.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ export class NgrxDefaultViewAdapter implements FormViewAdapter, AfterViewInit {
6060
constructor(
6161
private renderer: Renderer2,
6262
private elementRef: ElementRef,
63-
@Optional() @Inject(PLATFORM_ID) private readonly platformId: string,
63+
@Optional() @Inject(PLATFORM_ID) private platformId: string | null = null,
6464
// we use a special injection string that should never exist at runtime to allow mocking this dependency for testing
6565
@Optional() @Inject('ngrx-forms/never') navigator: Navigator | null = null,
6666
) {
67-
this.isCompositionSupported = isPlatformBrowser(this.platformId) && !isAndroid(navigator || window.navigator);
67+
this.isCompositionSupported = isPlatformBrowser(this.platformId || '') && !isAndroid(navigator || window.navigator);
6868
}
6969

7070
ngAfterViewInit() {

0 commit comments

Comments
 (0)