From 9bb09ebd893c3230c2949a19b3397950e2f77255 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 23 May 2019 16:42:45 +0200 Subject: [PATCH] chore: fix mdc-menu prototype not working with ivy Currently the `MatMenu` from the `@angular/material-experimental/mdc-menu` entry-point does not with Ivy as the base class (`MatMenu`) is not decorated and therefore Ivy is not able to generate the proper factory for the constructor. In order to fix this, we just create a pass-through constructor which ensures that dendency injection properly works. --- src/material-experimental/mdc-menu/menu.ts | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/material-experimental/mdc-menu/menu.ts b/src/material-experimental/mdc-menu/menu.ts index bea56f5b04e..b3a5eb4eefc 100644 --- a/src/material-experimental/mdc-menu/menu.ts +++ b/src/material-experimental/mdc-menu/menu.ts @@ -6,13 +6,23 @@ * found in the LICENSE file at https://angular.io/license */ -import {ChangeDetectionStrategy, Component, ViewEncapsulation, Provider} from '@angular/core'; import {Overlay, ScrollStrategy} from '@angular/cdk/overlay'; import { - MatMenu as BaseMatMenu, + ChangeDetectionStrategy, + Component, + ElementRef, + Inject, + NgZone, + Provider, + ViewEncapsulation +} from '@angular/core'; +import { + MAT_MENU_DEFAULT_OPTIONS, MAT_MENU_PANEL, - matMenuAnimations, MAT_MENU_SCROLL_STRATEGY, + MatMenu as BaseMatMenu, + matMenuAnimations, + MatMenuDefaultOptions, } from '@angular/material/menu'; /** @docs-private */ @@ -45,6 +55,13 @@ export const MAT_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER: Provider = { ] }) export class MatMenu extends BaseMatMenu { + + constructor(_elementRef: ElementRef, + _ngZone: NgZone, + @Inject(MAT_MENU_DEFAULT_OPTIONS) _defaultOptions: MatMenuDefaultOptions) { + super(_elementRef, _ngZone, _defaultOptions); + } + setElevation(_depth: number) { // TODO(crisbeto): MDC's styles come with elevation already and we haven't mapped our mixins // to theirs. Disable the elevation stacking for now until everything has been mapped.