Skip to content

Commit

Permalink
style(base): Use default param syntax in constructor
Browse files Browse the repository at this point in the history
The constructor of component was using a check for undefined to specify a default value instead of the new ES2015 syntax. Using the new syntax is clearer and more concise, since it shows the parameter is optional right where it is declared.
  • Loading branch information
AlexanderOtavka authored and traviskaufman committed Jan 9, 2017
1 parent f74685b commit 8efbf1f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/mdc-base/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export default class MDCComponent {
return new MDCComponent(root, new MDCFoundation());
}

constructor(root, foundation, ...args) {
constructor(root, foundation = this.getDefaultFoundation(), ...args) {
this.root_ = root;
this.initialize(...args);
this.foundation_ = foundation === undefined ? this.getDefaultFoundation() : foundation;
this.foundation_ = foundation;
this.foundation_.init();
this.initialSyncWithDOM();
}
Expand Down

1 comment on commit 8efbf1f

@nckh
Copy link
Contributor

@nckh nckh commented on 8efbf1f Feb 1, 2017

Choose a reason for hiding this comment

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

I'm having an issue when building custom vanilla components since this commit, because root_ is not available yet when getDefaultFoundation() is called. Is there another way to retrieve it? Thanks!

Please sign in to comment.