Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Commit

Permalink
fix(radio): Remove native control adapter methods (#1498)
Browse files Browse the repository at this point in the history
  • Loading branch information
trimox committed Oct 30, 2018
1 parent 2167c4b commit 8bec0d9
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/radio/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,14 @@ export class MdcRadio implements AfterViewInit, OnDestroy, MdcFormFieldControl<a
return {
addClass: (className: string) => this._getHostElement().classList.add(className),
removeClass: (className: string) => this._getHostElement().classList.remove(className),
getNativeControl: () => this._getInputElement()
setNativeControlDisabled: (disabled: boolean) => this.disabled = disabled
};
}

private _foundation: {
init(): void,
destroy(): void,
isChecked(): boolean,
setChecked(checked: boolean): void,
setDisabled(disabled: boolean): void,
isDisabled(): boolean,
getValue(): any,
setValue(value: any): void
setDisabled(disabled: boolean): void
} = new MDCRadioFoundation(this.createAdapter());

constructor(
Expand Down Expand Up @@ -232,7 +227,8 @@ export class MdcRadio implements AfterViewInit, OnDestroy, MdcFormFieldControl<a

if (this._checked !== newCheckedState) {
this._checked = newCheckedState;
this._foundation.setChecked(newCheckedState);
this._getInputElement().checked = newCheckedState;

if (newCheckedState && this.radioGroup && this.radioGroup.value !== this.value) {
this.radioGroup.selected = this;
} else if (!newCheckedState && this.radioGroup && this.radioGroup.value === this.value) {
Expand All @@ -253,7 +249,8 @@ export class MdcRadio implements AfterViewInit, OnDestroy, MdcFormFieldControl<a
setValue(value: any): void {
if (this._value !== value) {
this._value = value;
this._foundation.setValue(value);
this._getInputElement().value = this._value;

if (this.radioGroup !== null) {
if (!this.checked) {
// Update checked when the value changed to match the radio group's value
Expand Down

0 comments on commit 8bec0d9

Please sign in to comment.