Skip to content

Commit

Permalink
Remove use of WINDOW_PROVIDERS (#31)
Browse files Browse the repository at this point in the history
Seems to cause warnings when used like it was and potentially
compatibility issues with angular v11+
  • Loading branch information
JPedersen authored Nov 15, 2021
1 parent 7fc9b9e commit a80b2f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/window/window.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {ComponentFixture, TestBed} from '@angular/core/testing';

import {setupComponentTestingModule} from '../testing/test-lib';

import {WINDOW, WINDOW_PROVIDERS} from './window';
import {browserWindowProvider, WINDOW, windowProvider} from './window';

@Component({
selector: 'ph-window-test-host',
Expand All @@ -29,7 +29,8 @@ function setupWindowTestingModule(platformType: PlatformType) {
provide: PLATFORM_ID,
useValue: platformType,
},
...WINDOW_PROVIDERS,
browserWindowProvider,
windowProvider,
],
})
class MockWindowModule {}
Expand Down
8 changes: 3 additions & 5 deletions src/window/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,19 @@ export function windowFactory(
}
}

const browserWindowProvider: ClassProvider = {
export const browserWindowProvider: ClassProvider = {
provide: WindowRef,
useClass: BrowserWindowRef,
};

const windowProvider: FactoryProvider = {
export const windowProvider: FactoryProvider = {
provide: WINDOW,
useFactory: windowFactory,
deps: [WindowRef, PLATFORM_ID],
};

export const WINDOW_PROVIDERS = [browserWindowProvider, windowProvider];

@NgModule({
providers: [...WINDOW_PROVIDERS],
providers: [browserWindowProvider, windowProvider],
})
export class WindowModule {
}

0 comments on commit a80b2f8

Please sign in to comment.