Skip to content

Commit 0806b92

Browse files
committed
change isExpanded setter to private method
1 parent b14dec0 commit 0806b92

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/cdk/tree/tree.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,12 @@ export class CdkTreeNode<T> implements DoCheck, FocusableOption, OnDestroy, OnIn
346346
return this._tree.treeControl.isExpanded(this._data);
347347
}
348348

349-
set isExpanded(_expanded: boolean) {
350-
this._expanded = _expanded;
349+
private _setExpanded(_expanded: boolean) {
350+
this._isAriaExpanded = _expanded;
351351
this._elementRef.nativeElement.setAttribute('aria-expanded', `${_expanded}`);
352352
}
353353

354-
protected _expanded: boolean;
354+
protected _isAriaExpanded: boolean;
355355

356356
get level(): number {
357357
// If the treeControl has a getLevel method, use it to get the level. Otherwise read the
@@ -370,7 +370,7 @@ export class CdkTreeNode<T> implements DoCheck, FocusableOption, OnDestroy, OnIn
370370
// TODO: move to host after View Engine deprecation
371371
this._elementRef.nativeElement.classList.add('cdk-tree-node');
372372
this.role = 'treeitem';
373-
this.isExpanded = this.isExpanded;
373+
this._setExpanded(this.isExpanded);
374374
}
375375

376376
ngOnInit(): void {
@@ -383,8 +383,8 @@ export class CdkTreeNode<T> implements DoCheck, FocusableOption, OnDestroy, OnIn
383383
// the node isn't aware when the state is changed.
384384
// It is not set using a @HostBinding because they sometimes get lost with Mixin based classes.
385385
// TODO: move to host after View Engine deprecation
386-
if (this.isExpanded != this._expanded) {
387-
this.isExpanded = this.isExpanded;
386+
if (this.isExpanded != this._isAriaExpanded) {
387+
this._setExpanded(this.isExpanded);
388388
}
389389
}
390390

tools/public_api_guard/cdk/tree.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,11 @@ export declare class CdkTreeNode<T> implements DoCheck, FocusableOption, OnDestr
6969
_dataChanges: Subject<void>;
7070
protected _destroyed: Subject<void>;
7171
protected _elementRef: ElementRef<HTMLElement>;
72-
protected _expanded: boolean;
72+
protected _isAriaExpanded: boolean;
7373
protected _tree: CdkTree<T>;
7474
get data(): T;
7575
set data(value: T);
7676
get isExpanded(): boolean;
77-
set isExpanded(_expanded: boolean);
7877
get level(): number;
7978
get role(): 'treeitem' | 'group';
8079
set role(_role: 'treeitem' | 'group');

0 commit comments

Comments
 (0)