Skip to content

Commit 33b5d8c

Browse files
committed
refactor: don't depend on @Inject for _MatMenuBase DI
In Ivy, undecorated base classes (like _MatMenuBase) don't have the same behavior as View Engine; specifically, inheriting the constructor from the base class will not work in the DI system. Even in View Engine this was often counter-intuitive - only constructors with DI decorators would be properly inherited in JIT. This commit updates _MatMenuBase to not rely on this implementation detail of Angular, and instead moves the injected constructor onto _MatMenu itself.
1 parent 03a9a39 commit 33b5d8c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/material/menu/menu.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,4 +445,9 @@ export class MatMenu extends _MatMenuBase {}
445445
})
446446
// tslint:disable-next-line:class-name
447447
export class _MatMenu extends MatMenu {
448+
449+
constructor(elementRef: ElementRef<HTMLElement>, ngZone: NgZone,
450+
@Inject(MAT_MENU_DEFAULT_OPTIONS) defaultOptions: MatMenuDefaultOptions) {
451+
super(elementRef, ngZone, defaultOptions);
452+
}
448453
}

tools/public_api_guard/material/menu.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export declare class _MatMenu extends MatMenu {
2+
constructor(elementRef: ElementRef<HTMLElement>, ngZone: NgZone, defaultOptions: MatMenuDefaultOptions);
23
}
34

45
export declare class _MatMenuBase implements AfterContentInit, MatMenuPanel<MatMenuItem>, OnInit, OnDestroy {

0 commit comments

Comments
 (0)