@@ -23,7 +23,7 @@ import {
23
23
ViewEncapsulation ,
24
24
} from '@angular/core' ;
25
25
import { BehaviorSubject } from 'rxjs/BehaviorSubject' ;
26
- import { takeUntil } from 'rxjs/operators' ;
26
+ import { takeUntil } from 'rxjs/operators/takeUntil ' ;
27
27
import { Subject } from 'rxjs/Subject' ;
28
28
import { CdkTreeNodeDef , CdkTreeNode , CdkTreeNodeOutletContext } from './node' ;
29
29
import { CdkTreeNodeOutlet } from './outlet' ;
@@ -155,7 +155,7 @@ export class CdkTree<T> implements CollectionViewer, OnInit, OnDestroy {
155
155
156
156
/** Set up a subscription for the data provided by the data source. */
157
157
private _observeRenderChanges ( ) {
158
- takeUntil . call ( this . dataSource . connect ( this ) , this . _destroyed )
158
+ this . dataSource . connect ( this ) . pipe ( takeUntil ( this . _destroyed ) )
159
159
. subscribe ( data => {
160
160
this . _data = data ;
161
161
this . _renderNodeChanges ( data ) ;
@@ -191,7 +191,7 @@ export class CdkTree<T> implements CollectionViewer, OnInit, OnDestroy {
191
191
if ( this . _nodeDefs . length == 1 ) { return this . _nodeDefs . first ; }
192
192
193
193
const nodeDef =
194
- this . _nodeDefs . find ( def => def . when && def . when ( data , i ) ) || this . _defaultNodeDef ;
194
+ this . _nodeDefs . find ( def => def . when && def . when ( i , data ) ) || this . _defaultNodeDef ;
195
195
if ( ! nodeDef ) { throw getTreeMissingMatchingNodeDefError ( ) ; }
196
196
197
197
return nodeDef ;
@@ -214,7 +214,9 @@ export class CdkTree<T> implements CollectionViewer, OnInit, OnDestroy {
214
214
// Set the data to just created `CdkTreeNode`.
215
215
// The `CdkTreeNode` created from `createEmbeddedView` will be saved in static variable
216
216
// `mostRecentTreeNode`. We get it from static variable and pass the node data to it.
217
- CdkTreeNode . mostRecentTreeNode . data = nodeData ;
217
+ if ( CdkTreeNode . mostRecentTreeNode ) {
218
+ CdkTreeNode . mostRecentTreeNode . data = nodeData ;
219
+ }
218
220
219
221
this . _changeDetectorRef . detectChanges ( ) ;
220
222
}
0 commit comments