-
Notifications
You must be signed in to change notification settings - Fork 6.8k
chore: enforce consistency in material-examples #11539
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
chore: enforce consistency in material-examples #11539
Conversation
| node.children = this.buildFileTree(v, level + 1); | ||
| } else { | ||
| node.type = v; | ||
| buildFileTree(obj: object, level: number): FileNode[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obj: object is about as useful as value: any. Don't we know the type here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately we don't have the type, because we just parse a "stringified" JSON and it becomes any.
| }); | ||
| } | ||
|
|
||
| hasChild = (_: number, _nodeData: FileFlatNode) => { return _nodeData.expandable; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be reduced further to:
hasChild = (_: number, _nodeData: FileFlatNode) => _nodeData.expandable;| node.children = this.buildFileTree(v, level + 1); | ||
| } else { | ||
| node.type = v; | ||
| buildFileTree(obj: object, level: number): FileNode[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above. We should know the type of the obj here.
| hasNestedChild = (_: number, nodeData: FileNode) => { return !nodeData.type; }; | ||
|
|
||
| hasNestedChild = (_: number, nodeData: FileNode) => {return !(nodeData.type); }; | ||
| private _getChildren = (node: FileNode) => { return observableOf(node.children); }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two can be reduced to:
hasNestedChild = (_: number, nodeData: FileNode) => !nodeData.type;
private _getChildren = (node: FileNode) => observableOf(node.children);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one still hasn't been addressed @rafaelss95.
| <input matInput [matDatepicker]="dp3" placeholder="Input disabled" disabled> | ||
| <mat-datepicker-toggle matSuffix [for]="dp3"></mat-datepicker-toggle> | ||
| <mat-datepicker #dp3 disabled="false"></mat-datepicker> | ||
| <mat-datepicker #dp3 [disabled]="false"></mat-datepicker> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old usage was also valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, however shouldn't we prefer to pass the literal false instead of string with false value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we handle both strings and booleans, and the value doesn't change, it would be better to use the string binding. See the template syntax docs.
| export class FocusMonitorDirectivesExample { | ||
| elementOrigin: string = this.formatOrigin(null); | ||
| subtreeOrigin: string = this.formatOrigin(null); | ||
| elementOrigin = this.formatOrigin(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was the type removed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, formatOrigin returns a string, so elementOrigin is automatically inferred as string, there's no necessity to be redundant.
| let flatNode = this.nestedNodeMap.has(node) && this.nestedNodeMap.get(node)!.item === node.item | ||
| ? this.nestedNodeMap.get(node)! | ||
| : new TodoItemFlatNode(); | ||
| const existentNode = this.nestedNodeMap.get(node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
existentNode -> existingNode
| } | ||
| if (change.removed) { | ||
| change.removed.reverse().forEach((node) => this.toggleNode(node, false)); | ||
| change.removed.reverse().forEach(node => this.toggleNode(node, false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a good idea to add a slice() before the reverse here since reverse will reverse the array in place.
| transformer = (node: LoadmoreNode, level: number) => { | ||
| if (this.nodeMap.has(node.item)) { | ||
| return this.nodeMap.get(node.item)!; | ||
| const existentNode = this.nodeMap.get(node.item); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
existentNode -> existingNode
| hasNestedChild = (_: number, nodeData: FileNode) => { return !nodeData.type; }; | ||
|
|
||
| hasNestedChild = (_: number, nodeData: FileNode) => {return !(nodeData.type); }; | ||
| private _getChildren = (node: FileNode) => { return observableOf(node.children); }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be reduced to:
hasNestedChild = (_: number, nodeData: FileNode) => !nodeData.type;
private _getChildren = (node: FileNode) => observableOf(node.children);|
@crisbeto Ready for another review round. |
|
Hi @rafaelss95! This PR has merge conflicts due to recent upstream merges. |
|
@crisbeto is there something that I can do to speed up this PR? |
crisbeto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| hasNestedChild = (_: number, nodeData: FileNode) => { return !nodeData.type; }; | ||
|
|
||
| hasNestedChild = (_: number, nodeData: FileNode) => {return !(nodeData.type); }; | ||
| private _getChildren = (node: FileNode) => { return observableOf(node.children); }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one still hasn't been addressed @rafaelss95.
|
Done @crisbeto. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This:
ViewEncapsulation;.example-;@Inputs, like:<mat-horizontal-stepper linear="true">with sugar syntax<mat-horizontal-stepper linear>;