@@ -11,7 +11,6 @@ import {
11
11
MdNoPortalAttachedError ,
12
12
MdNullPortalError ,
13
13
MdPortalHostAlreadyDisposedError ,
14
- MdUnknownPortalTypeError
15
14
} from './portal-errors' ;
16
15
import { ComponentType } from '../overlay/generic-component-type' ;
17
16
@@ -149,7 +148,7 @@ export interface PortalHost {
149
148
150
149
/**
151
150
* Partial implementation of PortalHost that only deals with attaching either a
152
- * ComponentPortal or a TemplatePortal.
151
+ * ComponentPortal
153
152
*/
154
153
export abstract class BasePortalHost implements PortalHost {
155
154
/** The portal currently attached to the host. */
@@ -163,10 +162,10 @@ export abstract class BasePortalHost implements PortalHost {
163
162
164
163
/** Whether this host has an attached portal. */
165
164
hasAttached ( ) {
166
- return this . _attachedPortal != null ;
165
+ return this . _attachedPortal !== undefined ;
167
166
}
168
167
169
- attach ( portal : Portal < any > , newestOnTop : boolean ) : any {
168
+ attach ( portal : ComponentPortal < any > , newestOnTop : boolean ) : any {
170
169
if ( portal == null ) {
171
170
throw new MdNullPortalError ( ) ;
172
171
}
@@ -178,28 +177,20 @@ export abstract class BasePortalHost implements PortalHost {
178
177
if ( this . _isDisposed ) {
179
178
throw new MdPortalHostAlreadyDisposedError ( ) ;
180
179
}
181
-
182
- if ( portal instanceof ComponentPortal ) {
183
- this . _attachedPortal = portal ;
184
- return this . attachComponentPortal ( portal , newestOnTop ) ;
185
- } else if ( portal instanceof TemplatePortal ) {
186
- this . _attachedPortal = portal ;
187
- return this . attachTemplatePortal ( portal ) ;
188
- }
189
-
190
- throw new MdUnknownPortalTypeError ( ) ;
180
+ this . _attachedPortal = portal ;
181
+ return this . attachComponentPortal ( portal , newestOnTop ) ;
191
182
}
192
183
193
- abstract attachComponentPortal < T > ( portal : ComponentPortal < T > ,
194
- newestOnTop : boolean ) : ComponentRef < T > ;
195
-
196
- abstract attachTemplatePortal ( portal : TemplatePortal ) : Map < string , any > ;
184
+ abstract attachComponentPortal < T > (
185
+ portal : ComponentPortal < T > ,
186
+ newestOnTop : boolean
187
+ ) : ComponentRef < T > ;
197
188
198
189
detach ( ) : void {
199
190
if ( this . _attachedPortal ) { this . _attachedPortal . setAttachedHost ( null ) ; }
200
191
201
192
this . _attachedPortal = null ;
202
- if ( this . _disposeFn != null ) {
193
+ if ( this . _disposeFn ) {
203
194
this . _disposeFn ( ) ;
204
195
this . _disposeFn = null ;
205
196
}
0 commit comments