Skip to content

refactor(tree): ensure input is applied to the getter and not the setter #10764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cdk/tree/padding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ export class CdkTreeNodePadding<T> implements OnDestroy {

/** The level of depth of the tree node. The padding will be `level * indent` pixels. */
@Input('cdkTreeNodePadding')
get level(): number { return this._level; }
set level(value: number) {
this._level = coerceNumberProperty(value);
this._setPadding();
}
get level(): number { return this._level; }
_level: number;

/** The indent for each level. Default number 40px from material design menu sub-menu spec. */
// TODO(tinayuangao): Make indent working with a string with unit, e.g. 10em
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tinayuangao Not related to this PR, but can't this be done using coerceCssPixelValue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coerceCssPixelValue got in recently so it probably wasn't there when the tree was implemented.

@Input('cdkTreeNodePaddingIndent')
get indent(): number { return this._indent; }
set indent(value: number) {
this._indent = coerceNumberProperty(value);
this._setPadding();
}
get indent(): number { return this._indent; }
_indent: number = 40;

constructor(private _treeNode: CdkTreeNode<T>,
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/tree/tree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,8 @@ class FakeDataSource extends DataSource<TestData> {
isConnected = false;

_dataChange = new BehaviorSubject<TestData[]>([]);
set data(data: TestData[]) { this._dataChange.next(data); }
get data() { return this._dataChange.getValue(); }
set data(data: TestData[]) { this._dataChange.next(data); }

constructor(public treeControl: TreeControl<TestData>) {
super();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tree/tree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ export class TestData {
class FakeDataSource {
dataIndex = 0;
_dataChange = new BehaviorSubject<TestData[]>([]);
set data(data: TestData[]) { this._dataChange.next(data); }
get data() { return this._dataChange.getValue(); }
set data(data: TestData[]) { this._dataChange.next(data); }

connect(): Observable<TestData[]> {
return this._dataChange;
Expand Down