Skip to content

Commit ad9a601

Browse files
committed
clarify adding class directly to elementRef instead of on host property
1 parent 64addca commit ad9a601

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

src/cdk/tree/nested-node.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export class CdkNestedTreeNode<T> extends CdkTreeNode<T> implements AfterContent
6161
protected _tree: CdkTree<T>,
6262
protected _differs: IterableDiffers) {
6363
super(_elementRef, _tree);
64+
// The classes are directly added here instead of in the host property because classes on
65+
// the host property are not inherited with View Engine.
6466
this._elementRef.nativeElement.classList.add('cdk-tree-node', 'cdk-nested-tree-node');
6567
}
6668

src/cdk/tree/tree.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ export class CdkTreeNode<T> implements FocusableOption, OnDestroy, OnInit {
350350
constructor(protected _elementRef: ElementRef<HTMLElement>,
351351
protected _tree: CdkTree<T>) {
352352
CdkTreeNode.mostRecentTreeNode = this as CdkTreeNode<T>;
353+
// The classes are directly added here instead of in the host property because classes on
354+
// the host property are not inherited with View Engine.
353355
this._elementRef.nativeElement.classList.add('cdk-tree-node');
354356
}
355357

@@ -385,7 +387,6 @@ export class CdkTreeNode<T> implements FocusableOption, OnDestroy, OnInit {
385387
}
386388

387389
function getParentNodeAriaLevel(nodeElement: HTMLElement): number {
388-
debugger;
389390
let parent = nodeElement.parentElement;
390391
while (parent && isNodeElement(parent)) {
391392
parent = parent.parentElement;

src/material/tree/node.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ export class MatTreeNode<T> extends _MatTreeNodeMixinBase<T>
5959
super(_elementRef, _tree);
6060

6161
this.tabIndex = Number(tabIndex) || 0;
62+
// The classes are directly added here instead of in the host property because classes on
63+
// the host property are not inherited with View Engine.
6264
this._elementRef.nativeElement.classList.add('mat-tree-node');
6365
}
6466

@@ -121,6 +123,8 @@ export class MatNestedTreeNode<T> extends CdkNestedTreeNode<T> implements AfterC
121123
@Attribute('tabindex') tabIndex: string) {
122124
super(_elementRef, _tree, _differs);
123125
this.tabIndex = Number(tabIndex) || 0;
126+
// The classes are directly added here instead of in the host property because classes on
127+
// the host property are not inherited with View Engine.
124128
this._elementRef.nativeElement.classList.add('mat-nested-tree-node');
125129
}
126130

tools/public_api_guard/cdk/tree.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export declare class CdkNestedTreeNode<T> extends CdkTreeNode<T> implements Afte
4040
export declare class CdkTree<T> implements AfterContentChecked, CollectionViewer, OnDestroy, OnInit {
4141
_nodeDefs: QueryList<CdkTreeNodeDef<T>>;
4242
_nodeOutlet: CdkTreeNodeOutlet;
43-
_role: string;
4443
get dataSource(): DataSource<T> | Observable<T[]> | T[];
4544
set dataSource(dataSource: DataSource<T> | Observable<T[]> | T[]);
4645
trackBy: TrackByFunction<T>;
@@ -49,7 +48,7 @@ export declare class CdkTree<T> implements AfterContentChecked, CollectionViewer
4948
start: number;
5049
end: number;
5150
}>;
52-
constructor(_differs: IterableDiffers, _changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef<HTMLElement>);
51+
constructor(_differs: IterableDiffers, _changeDetectorRef: ChangeDetectorRef);
5352
_getNodeDef(data: T, i: number): CdkTreeNodeDef<T>;
5453
insertNode(nodeData: T, index: number, viewContainer?: ViewContainerRef, parentData?: T): void;
5554
ngAfterContentChecked(): void;

tools/public_api_guard/material/tree.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export declare class MatNestedTreeNode<T> extends CdkNestedTreeNode<T> implement
1717

1818
export declare class MatTree<T> extends CdkTree<T> {
1919
_nodeOutlet: MatTreeNodeOutlet;
20-
constructor(_differs: IterableDiffers, _changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef<HTMLElement>);
2120
static ɵcmp: i0.ɵɵComponentDefWithMeta<MatTree<any>, "mat-tree", ["matTree"], {}, {}, never, never>;
2221
static ɵfac: i0.ɵɵFactoryDef<MatTree<any>, never>;
2322
}

0 commit comments

Comments
 (0)