Skip to content

chore(snack-bar): rename MdSnackBarRef instance to componentInstance #6566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 changes: 1 addition & 1 deletion src/lib/snack-bar/snack-bar-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {MdSnackBarContainer} from './snack-bar-container';
*/
export class MdSnackBarRef<T> {
/** The instance of the component making up the content of the snack bar. */
instance: T;
componentInstance: T;

/**
* The instance of the component making up the content of the snack bar.
Expand Down
18 changes: 10 additions & 8 deletions src/lib/snack-bar/snack-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ describe('MdSnackBar', () => {

viewContainerFixture.detectChanges();

expect(snackBarRef.instance instanceof SimpleSnackBar)
expect(snackBarRef.componentInstance instanceof SimpleSnackBar)
.toBe(true, 'Expected the snack bar content component to be SimpleSnackBar');
expect(snackBarRef.instance.snackBarRef)

expect(snackBarRef.componentInstance.snackBarRef)
.toBe(snackBarRef,
'Expected the snack bar reference to be placed in the component instance');

Expand All @@ -119,9 +120,9 @@ describe('MdSnackBar', () => {

viewContainerFixture.detectChanges();

expect(snackBarRef.instance instanceof SimpleSnackBar)
expect(snackBarRef.componentInstance instanceof SimpleSnackBar)
.toBe(true, 'Expected the snack bar content component to be SimpleSnackBar');
expect(snackBarRef.instance.snackBarRef)
expect(snackBarRef.componentInstance.snackBarRef)
.toBe(snackBarRef, 'Expected the snack bar reference to be placed in the component instance');

let messageElement = overlayContainerElement.querySelector('snack-bar-container')!;
Expand Down Expand Up @@ -391,7 +392,7 @@ describe('MdSnackBar', () => {
it('should open a custom component', () => {
const snackBarRef = snackBar.openFromComponent(BurritosNotification);

expect(snackBarRef.instance instanceof BurritosNotification)
expect(snackBarRef.componentInstance instanceof BurritosNotification)
.toBe(true, 'Expected the snack bar content component to be BurritosNotification');
expect(overlayContainerElement.textContent!.trim())
.toBe('Burritos are on the way.', 'Expected component to have the proper text.');
Expand All @@ -400,7 +401,7 @@ describe('MdSnackBar', () => {
it('should inject the snack bar reference into the component', () => {
const snackBarRef = snackBar.openFromComponent(BurritosNotification);

expect(snackBarRef.instance.snackBarRef)
expect(snackBarRef.componentInstance.snackBarRef)
.toBe(snackBarRef, 'Expected component to have an injected snack bar reference.');
});

Expand All @@ -411,8 +412,9 @@ describe('MdSnackBar', () => {
}
});

expect(snackBarRef.instance.data).toBeTruthy('Expected component to have a data object.');
expect(snackBarRef.instance.data.burritoType)
expect(snackBarRef.componentInstance.data)
.toBeTruthy('Expected component to have a data object.');
expect(snackBarRef.componentInstance.data.burritoType)
.toBe('Chimichanga', 'Expected the injected data object to be the one the user provided.');
});

Expand Down
2 changes: 1 addition & 1 deletion src/lib/snack-bar/snack-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class MdSnackBar {
const contentRef = container.attachComponentPortal(portal);

// We can't pass this via the injector, because the injector is created earlier.
snackBarRef.instance = contentRef.instance;
snackBarRef.componentInstance = contentRef.instance;

return snackBarRef;
}
Expand Down