From 10c546ceede20eb0c4d955c4eac97a1e7b152c62 Mon Sep 17 00:00:00 2001 From: Alex Rickabaugh Date: Fri, 10 May 2019 13:27:40 -0700 Subject: [PATCH] refactor: don't depend on @Inject for _MatMenuBase DI (#15975) 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. --- src/material/menu/menu.ts | 5 +++++ tools/public_api_guard/material/menu.d.ts | 1 + 2 files changed, 6 insertions(+) diff --git a/src/material/menu/menu.ts b/src/material/menu/menu.ts index 00bd044ebb3..1710c866379 100644 --- a/src/material/menu/menu.ts +++ b/src/material/menu/menu.ts @@ -445,4 +445,9 @@ export class MatMenu extends _MatMenuBase {} }) // tslint:disable-next-line:class-name export class _MatMenu extends MatMenu { + + constructor(elementRef: ElementRef, ngZone: NgZone, + @Inject(MAT_MENU_DEFAULT_OPTIONS) defaultOptions: MatMenuDefaultOptions) { + super(elementRef, ngZone, defaultOptions); + } } diff --git a/tools/public_api_guard/material/menu.d.ts b/tools/public_api_guard/material/menu.d.ts index 0e54f01eb83..4e9a2d7c3df 100644 --- a/tools/public_api_guard/material/menu.d.ts +++ b/tools/public_api_guard/material/menu.d.ts @@ -1,4 +1,5 @@ export declare class _MatMenu extends MatMenu { + constructor(elementRef: ElementRef, ngZone: NgZone, defaultOptions: MatMenuDefaultOptions); } export declare class _MatMenuBase implements AfterContentInit, MatMenuPanel, OnInit, OnDestroy {