Skip to content

Commit e8dc761

Browse files
committed
Move factory functions into exported constants, fixes AoT
1 parent 23dca21 commit e8dc761

File tree

6 files changed

+42
-27
lines changed

6 files changed

+42
-27
lines changed

src/lib/core/a11y/live-announcer.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,16 @@ export class LiveAnnouncer {
6464

6565
}
6666

67+
export function LIVE_ANNOUNCER_PROVIDER_FACTORY(parentDispatcher: LiveAnnouncer, liveElement: any) {
68+
return parentDispatcher || new LiveAnnouncer(liveElement);
69+
};
70+
6771
export const LIVE_ANNOUNCER_PROVIDER = {
68-
// If there is already an LiveAnnouncer available, use that. Otherwise, provide a new one.
72+
// If there is already a LiveAnnouncer available, use that. Otherwise, provide a new one.
6973
provide: LiveAnnouncer,
7074
deps: [
7175
[new Optional(), new SkipSelf(), LiveAnnouncer],
7276
[new Optional(), new Inject(LIVE_ANNOUNCER_ELEMENT_TOKEN)]
7377
],
74-
useFactory: (parentDispatcher: LiveAnnouncer, ariaLiveElement: any) => {
75-
return parentDispatcher || new LiveAnnouncer(ariaLiveElement);
76-
}
78+
useFactory: LIVE_ANNOUNCER_PROVIDER_FACTORY
7779
};

src/lib/core/coordination/unique-selection-dispatcher.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@ export class UniqueSelectionDispatcher {
3434
}
3535
}
3636

37+
export function UNIQUE_SELECTION_DISPATCHER_PROVIDER_FACTORY(
38+
parentDispatcher: UniqueSelectionDispatcher) {
39+
return parentDispatcher || new UniqueSelectionDispatcher();
40+
}
41+
3742
export const UNIQUE_SELECTION_DISPATCHER_PROVIDER = {
43+
// If there is already a dispatcher available, use that. Otherwise, provide a new one.
3844
provide: UniqueSelectionDispatcher,
3945
deps: [[new Optional(), new SkipSelf(), UniqueSelectionDispatcher]],
40-
useFactory: (parentDispatcher: UniqueSelectionDispatcher) => {
41-
return parentDispatcher || new UniqueSelectionDispatcher();
42-
}
46+
useFactory: UNIQUE_SELECTION_DISPATCHER_PROVIDER_FACTORY
4347
};

src/lib/core/overlay/overlay-container.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ export class OverlayContainer {
3232
}
3333
}
3434

35+
export function OVERLAY_CONTAINER_PROVIDER_FACTORY(parentContainer: OverlayContainer) {
36+
return parentContainer || new OverlayContainer();
37+
};
38+
3539
export const OVERLAY_CONTAINER_PROVIDER = {
3640
// If there is already an OverlayContainer available, use that. Otherwise, provide a new one.
3741
provide: OverlayContainer,
3842
deps: [[new Optional(), new SkipSelf(), OverlayContainer]],
39-
useFactory: (parentContainer: OverlayContainer) => {
40-
return parentContainer || new OverlayContainer();
41-
}
43+
useFactory: OVERLAY_CONTAINER_PROVIDER_FACTORY
4244
};

src/lib/core/overlay/position/viewport-ruler.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ export class ViewportRuler {
5656
}
5757
}
5858

59+
export function VIEWPORT_RULER_PROVIDER_FACTORY(parentDispatcher: ViewportRuler) {
60+
return parentDispatcher || new ViewportRuler();
61+
};
62+
5963
export const VIEWPORT_RULER_PROVIDER = {
60-
// If there is already an ViewportRuler available, use that. Otherwise, provide a new one.
64+
// If there is already a ViewportRuler available, use that. Otherwise, provide a new one.
6165
provide: ViewportRuler,
6266
deps: [[new Optional(), new SkipSelf(), ViewportRuler]],
63-
useFactory: (parentDispatcher: ViewportRuler) => {
64-
return parentDispatcher || new ViewportRuler();
65-
}
67+
useFactory: VIEWPORT_RULER_PROVIDER_FACTORY
6668
};

src/lib/core/overlay/scroll/scroll-dispatcher.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@ export class ScrollDispatcher {
8888
}
8989
}
9090

91+
export function SCROLL_DISPATCHER_PROVIDER_FACTORY(parentDispatcher: ScrollDispatcher) {
92+
return parentDispatcher || new ScrollDispatcher();
93+
};
94+
9195
export const SCROLL_DISPATCHER_PROVIDER = {
92-
// If there is already an ScrollDispatcher available, use that. Otherwise, provide a new one.
96+
// If there is already a ScrollDispatcher available, use that. Otherwise, provide a new one.
9397
provide: ScrollDispatcher,
9498
deps: [[new Optional(), new SkipSelf(), ScrollDispatcher]],
95-
useFactory: (parentDispatcher: ScrollDispatcher) => {
96-
return parentDispatcher || new ScrollDispatcher();
97-
}
99+
useFactory: SCROLL_DISPATCHER_PROVIDER_FACTORY
98100
};

src/lib/icon/icon.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -247,20 +247,23 @@ export class MdIcon implements OnChanges, OnInit, AfterViewChecked {
247247
}
248248
}
249249

250+
export function ICON_REGISTRY_PROVIDER_FACTORY(
251+
parentRegistry: MdIconRegistry, http: Http, sanitizer: DomSanitizer) {
252+
return parentRegistry || new MdIconRegistry(http, sanitizer);
253+
};
254+
255+
export const ICON_REGISTRY_PROVIDER = {
256+
// If there is already an MdIconRegistry available, use that. Otherwise, provide a new one.
257+
provide: MdIconRegistry,
258+
deps: [[new Optional(), new SkipSelf(), MdIconRegistry], Http, DomSanitizer],
259+
useFactory: ICON_REGISTRY_PROVIDER_FACTORY,
260+
};
250261

251262
@NgModule({
252263
imports: [HttpModule, DefaultStyleCompatibilityModeModule],
253264
exports: [MdIcon, DefaultStyleCompatibilityModeModule],
254265
declarations: [MdIcon],
255-
providers: [{
256-
// If there is already an MdIconRegistry available, use that. Otherwise, provide a new one.
257-
provide: MdIconRegistry,
258-
deps: [[new Optional(), new SkipSelf(), MdIconRegistry], Http, DomSanitizer],
259-
useFactory: (parentRegistry: MdIconRegistry, http: Http, sanitizer: DomSanitizer) => {
260-
return parentRegistry || new MdIconRegistry(http, sanitizer);
261-
},
262-
}
263-
]
266+
providers: [ICON_REGISTRY_PROVIDER],
264267
})
265268
export class MdIconModule {
266269
/** @deprecated */

0 commit comments

Comments
 (0)