Skip to content

Commit

Permalink
refactor(dialog,bottom-sheet): remove extra generic for return type
Browse files Browse the repository at this point in the history
Removes the `R` generic, because it always ends up as `any` in the result subscriptions.

Fixes angular#12898.
  • Loading branch information
crisbeto committed Sep 6, 2018
1 parent 4ddbde9 commit eff9926
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/lib/bottom-sheet/bottom-sheet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, any, number>(PizzaMsg);
const bottomSheetRef = bottomSheet.open<PizzaMsg>(PizzaMsg);
const spy = jasmine.createSpy('afterDismissed spy');

bottomSheetRef.afterDismissed().subscribe(spy);
Expand Down
14 changes: 7 additions & 7 deletions src/lib/bottom-sheet/bottom-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ export class MatBottomSheet {
@Optional() @SkipSelf() private _parentBottomSheet: MatBottomSheet,
@Optional() private _location?: Location) {}

open<T, D = any, R = any>(component: ComponentType<T>,
config?: MatBottomSheetConfig<D>): MatBottomSheetRef<T, R>;
open<T, D = any, R = any>(template: TemplateRef<T>,
config?: MatBottomSheetConfig<D>): MatBottomSheetRef<T, R>;
open<T, D = any>(component: ComponentType<T>,
config?: MatBottomSheetConfig<D>): MatBottomSheetRef<T>;
open<T, D = any>(template: TemplateRef<T>,
config?: MatBottomSheetConfig<D>): MatBottomSheetRef<T>;

open<T, D = any, R = any>(componentOrTemplateRef: ComponentType<T> | TemplateRef<T>,
config?: MatBottomSheetConfig<D>): MatBottomSheetRef<T, R> {
open<T, D = any>(componentOrTemplateRef: ComponentType<T> | TemplateRef<T>,
config?: MatBottomSheetConfig<D>): MatBottomSheetRef<T> {

const _config = _applyConfigDefaults(config);
const overlayRef = this._createOverlay(_config);
const container = this._attachContainer(overlayRef, _config);
const ref = new MatBottomSheetRef<T, R>(container, overlayRef, this._location);
const ref = new MatBottomSheetRef<T>(container, overlayRef, this._location);

if (componentOrTemplateRef instanceof TemplateRef) {
container.attachTemplatePortal(new TemplatePortal<T>(componentOrTemplateRef, null!, {
Expand Down
39 changes: 19 additions & 20 deletions src/lib/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ export class MatDialog {
* @param config Extra configuration options.
* @returns Reference to the newly-opened dialog.
*/
open<T, D = any, R = any>(componentOrTemplateRef: ComponentType<T> | TemplateRef<T>,
config?: MatDialogConfig<D>): MatDialogRef<T, R> {
open<T, D = any>(componentOrTemplateRef: ComponentType<T> | TemplateRef<T>,
config?: MatDialogConfig<D>): MatDialogRef<T> {

config = _applyConfigDefaults(config, this._defaultOptions || new MatDialogConfig());

Expand All @@ -131,10 +131,10 @@ export class MatDialog {

const overlayRef = this._createOverlay(config);
const dialogContainer = this._attachDialogContainer(overlayRef, config);
const dialogRef = this._attachDialogContent<T, R>(componentOrTemplateRef,
dialogContainer,
overlayRef,
config);
const dialogRef = this._attachDialogContent<T>(componentOrTemplateRef,
dialogContainer,
overlayRef,
config);

// If this is the first dialog that we're opening, hide all the non-overlay content.
if (!this.openDialogs.length) {
Expand Down Expand Up @@ -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<T, R>(
private _attachDialogContent<T>(
componentOrTemplateRef: ComponentType<T> | TemplateRef<T>,
dialogContainer: MatDialogContainer,
overlayRef: OverlayRef,
config: MatDialogConfig): MatDialogRef<T, R> {
config: MatDialogConfig): MatDialogRef<T> {

// 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<T, R>(overlayRef, dialogContainer, this._location, config.id);
const dialogRef = new MatDialogRef<T>(overlayRef, dialogContainer, this._location, config.id);

// When the dialog backdrop is clicked, we want to close it.
if (config.hasBackdrop) {
Expand Down Expand Up @@ -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');
}
}

}

}
Expand Down

0 comments on commit eff9926

Please sign in to comment.