diff --git a/src/lib/bottom-sheet/bottom-sheet.spec.ts b/src/lib/bottom-sheet/bottom-sheet.spec.ts index ea1fa9c18884..d6f4152f8a1e 100644 --- a/src/lib/bottom-sheet/bottom-sheet.spec.ts +++ b/src/lib/bottom-sheet/bottom-sheet.spec.ts @@ -343,7 +343,7 @@ describe('MatBottomSheet', () => { })); it('should be able to pass a result back to the dismissed stream', fakeAsync(() => { - const bottomSheetRef = bottomSheet.open(PizzaMsg); + const bottomSheetRef = bottomSheet.open(PizzaMsg); const spy = jasmine.createSpy('afterDismissed spy'); bottomSheetRef.afterDismissed().subscribe(spy); diff --git a/src/lib/bottom-sheet/bottom-sheet.ts b/src/lib/bottom-sheet/bottom-sheet.ts index 8c6fc9f354fc..3a4c68b23ada 100644 --- a/src/lib/bottom-sheet/bottom-sheet.ts +++ b/src/lib/bottom-sheet/bottom-sheet.ts @@ -45,18 +45,18 @@ export class MatBottomSheet { @Optional() @SkipSelf() private _parentBottomSheet: MatBottomSheet, @Optional() private _location?: Location) {} - open(component: ComponentType, - config?: MatBottomSheetConfig): MatBottomSheetRef; - open(template: TemplateRef, - config?: MatBottomSheetConfig): MatBottomSheetRef; + open(component: ComponentType, + config?: MatBottomSheetConfig): MatBottomSheetRef; + open(template: TemplateRef, + config?: MatBottomSheetConfig): MatBottomSheetRef; - open(componentOrTemplateRef: ComponentType | TemplateRef, - config?: MatBottomSheetConfig): MatBottomSheetRef { + open(componentOrTemplateRef: ComponentType | TemplateRef, + config?: MatBottomSheetConfig): MatBottomSheetRef { const _config = _applyConfigDefaults(config); const overlayRef = this._createOverlay(_config); const container = this._attachContainer(overlayRef, _config); - const ref = new MatBottomSheetRef(container, overlayRef, this._location); + const ref = new MatBottomSheetRef(container, overlayRef, this._location); if (componentOrTemplateRef instanceof TemplateRef) { container.attachTemplatePortal(new TemplatePortal(componentOrTemplateRef, null!, { diff --git a/src/lib/dialog/dialog.ts b/src/lib/dialog/dialog.ts index d7d6f239b6c9..5b13696533e9 100644 --- a/src/lib/dialog/dialog.ts +++ b/src/lib/dialog/dialog.ts @@ -120,8 +120,8 @@ export class MatDialog { * @param config Extra configuration options. * @returns Reference to the newly-opened dialog. */ - open(componentOrTemplateRef: ComponentType | TemplateRef, - config?: MatDialogConfig): MatDialogRef { + open(componentOrTemplateRef: ComponentType | TemplateRef, + config?: MatDialogConfig): MatDialogRef { config = _applyConfigDefaults(config, this._defaultOptions || new MatDialogConfig()); @@ -131,10 +131,10 @@ export class MatDialog { const overlayRef = this._createOverlay(config); const dialogContainer = this._attachDialogContainer(overlayRef, config); - const dialogRef = this._attachDialogContent(componentOrTemplateRef, - dialogContainer, - overlayRef, - config); + const dialogRef = this._attachDialogContent(componentOrTemplateRef, + dialogContainer, + overlayRef, + config); // If this is the first dialog that we're opening, hide all the non-overlay content. if (!this.openDialogs.length) { @@ -233,16 +233,15 @@ export class MatDialog { * @param config The dialog configuration. * @returns A promise resolving to the MatDialogRef that should be returned to the user. */ - private _attachDialogContent( + private _attachDialogContent( componentOrTemplateRef: ComponentType | TemplateRef, dialogContainer: MatDialogContainer, overlayRef: OverlayRef, - config: MatDialogConfig): MatDialogRef { + config: MatDialogConfig): MatDialogRef { // Create a reference to the dialog we're creating in order to give the user a handle // to modify and close it. - const dialogRef = - new MatDialogRef(overlayRef, dialogContainer, this._location, config.id); + const dialogRef = new MatDialogRef(overlayRef, dialogContainer, this._location, config.id); // When the dialog backdrop is clicked, we want to close it. if (config.hasBackdrop) { @@ -341,23 +340,23 @@ export class MatDialog { const overlayContainer = this._overlayContainer.getContainerElement(); // Ensure that the overlay container is attached to the DOM. - if (overlayContainer.parentElement) { - const siblings = overlayContainer.parentElement.children; + if (!overlayContainer.parentElement) { + return; + } + + const siblings = overlayContainer.parentElement.children; - for (let i = siblings.length - 1; i > -1; i--) { - let sibling = siblings[i]; + for (let i = siblings.length - 1; i > -1; i--) { + let sibling = siblings[i]; - if (sibling !== overlayContainer && + if (sibling !== overlayContainer && sibling.nodeName !== 'SCRIPT' && sibling.nodeName !== 'STYLE' && !sibling.hasAttribute('aria-live')) { - - this._ariaHiddenElements.set(sibling, sibling.getAttribute('aria-hidden')); - sibling.setAttribute('aria-hidden', 'true'); - } + this._ariaHiddenElements.set(sibling, sibling.getAttribute('aria-hidden')); + sibling.setAttribute('aria-hidden', 'true'); } } - } }