Skip to content

Commit

Permalink
WIP: checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Goo committed Aug 27, 2018
1 parent 1ee6735 commit 0f7fecc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
4 changes: 4 additions & 0 deletions packages/mdc-checkbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ If you are using a JavaScript framework, such as React or Angular, you can creat
| `getNativeControl() => HTMLInputElement?` | Returns the native checkbox control, if available. Note that if this control is not available, the methods that rely on it will exit gracefully.|
| `forceLayout() => void` | Force-trigger a layout on the root element. This is needed to restart animations correctly. If you find that you do not need to do this, you can simply make it a no-op. |
| `isAttachedToDOM() => boolean` | Returns true if the component is currently attached to the DOM, false otherwise. |
| `isIndeterminate() => boolean` | Returns true if the component is in the indeterminate state. |
| `isChecked() => boolean` | Returns true if the component is checked. |
| `hasNativeControl() => boolean` | Returns true if the input is present in the component. |
| `setNativeControlDisabled(disabled: boolean) => void` | Sets the input to disabled. |

### `MDCCheckboxFoundation`

Expand Down
24 changes: 4 additions & 20 deletions packages/mdc-checkbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,39 +93,23 @@ class MDCCheckbox extends MDCComponent {
setNativeControlAttr: (attr, value) => this.nativeCb_.setAttribute(attr, value),
removeNativeControlAttr: (attr) => this.nativeCb_.removeAttribute(attr),
getNativeControl: () => this.nativeCb_,
isIndeterminate: () => this.isIndeterminate_(),
isChecked: () => this.isChecked_(),
isIndeterminate: () => this.indeterminate,
isChecked: () => this.checked,
hasNativeControl: () => !!this.nativeCb_,
setNativeControlDisabled: (disabled) => this.nativeCb_.disabled = disabled,
forceLayout: () => this.root_.offsetWidth,
isAttachedToDOM: () => Boolean(this.root_.parentNode),
});
}

/**
* @return {boolean}
* @private
*/
isIndeterminate_() {
return this.nativeCb_.indeterminate;
}

/**
* @return {boolean}
* @private
*/
isChecked_() {
return this.nativeCb_.checked;
}

/** @return {!MDCRipple} */
get ripple() {
return this.ripple_;
}

/** @return {boolean} */
get checked() {
return this.isChecked_();
return this.nativeCb_.checked;
}

/** @param {boolean} checked */
Expand All @@ -135,7 +119,7 @@ class MDCCheckbox extends MDCComponent {

/** @return {boolean} */
get indeterminate() {
return this.isIndeterminate_();
return this.nativeCb_.indeterminate;
}

/** @param {boolean} indeterminate */
Expand Down

0 comments on commit 0f7fecc

Please sign in to comment.