@@ -123,8 +123,8 @@ export class CdkTree<T> implements CollectionViewer, OnInit, OnDestroy {
123
123
this . _onDestroy . next ( ) ;
124
124
this . _onDestroy . complete ( ) ;
125
125
126
- if ( this . dataSource instanceof DataSource ) {
127
- this . dataSource . disconnect ( this ) ;
126
+ if ( this . _dataSource && typeof ( this . _dataSource as DataSource < T > ) . disconnect === 'function' ) {
127
+ ( this . dataSource as DataSource < T > ) . disconnect ( this ) ;
128
128
}
129
129
130
130
if ( this . _dataSubscription ) {
@@ -157,8 +157,8 @@ export class CdkTree<T> implements CollectionViewer, OnInit, OnDestroy {
157
157
private _switchDataSource ( dataSource : DataSource < T > | Observable < T [ ] > | T [ ] ) {
158
158
this . _data = new Array < T > ( ) ;
159
159
160
- if ( this . dataSource instanceof DataSource ) {
161
- this . dataSource . disconnect ( this ) ;
160
+ if ( this . _dataSource && typeof ( this . _dataSource as DataSource < T > ) . disconnect === 'function' ) {
161
+ ( this . dataSource as DataSource < T > ) . disconnect ( this ) ;
162
162
}
163
163
164
164
if ( this . _dataSubscription ) {
@@ -183,7 +183,7 @@ export class CdkTree<T> implements CollectionViewer, OnInit, OnDestroy {
183
183
184
184
// Cannot use `instanceof DataSource` since the data source could be a literal with
185
185
// `connect` function and may not extends DataSource.
186
- if ( ( this . _dataSource as DataSource < T > ) . connect instanceof Function ) {
186
+ if ( typeof ( this . _dataSource as DataSource < T > ) . connect === 'function' ) {
187
187
dataStream = ( this . _dataSource as DataSource < T > ) . connect ( this ) ;
188
188
} else if ( this . _dataSource instanceof Observable ) {
189
189
dataStream = this . _dataSource ;
0 commit comments