From f6f1dd62b089175343c3cc54c6dc2ed83adecc0e Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Mon, 16 May 2022 09:04:22 +0200 Subject: [PATCH] refactor(material-experimental/mdc-radio): remove adapter usage Removes the dependency on the MDC radio adapter from the radio button component. --- .../mdc-radio/radio.html | 2 +- src/material-experimental/mdc-radio/radio.ts | 43 +------------------ 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/src/material-experimental/mdc-radio/radio.html b/src/material-experimental/mdc-radio/radio.html index f6f3b116600a..3ac71037faa5 100644 --- a/src/material-experimental/mdc-radio/radio.html +++ b/src/material-experimental/mdc-radio/radio.html @@ -1,6 +1,6 @@
-
+
{ encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, }) -export class MatRadioButton extends _MatRadioButtonBase implements AfterViewInit, OnDestroy { - private _radioAdapter: MDCRadioAdapter = { - addClass: (className: string) => this._setClass(className, true), - removeClass: (className: string) => this._setClass(className, false), - setNativeControlDisabled: (disabled: boolean) => { - if (this.disabled !== disabled) { - this.disabled = disabled; - this._changeDetector.markForCheck(); - } - }, - }; - - _radioFoundation = new MDCRadioFoundation(this._radioAdapter); - _classes: {[key: string]: boolean} = {}; - +export class MatRadioButton extends _MatRadioButtonBase { constructor( @Optional() @Inject(MAT_RADIO_GROUP) radioGroup: MatRadioGroup, elementRef: ElementRef, @@ -145,28 +128,4 @@ export class MatRadioButton extends _MatRadioButtonBase implements AfterViewInit tabIndex, ); } - - override ngAfterViewInit() { - super.ngAfterViewInit(); - this._radioFoundation.init(); - } - - override ngOnDestroy() { - super.ngOnDestroy(); - this._radioFoundation.destroy(); - } - - private _setClass(cssClass: string, active: boolean) { - this._classes = {...this._classes, [cssClass]: active}; - this._changeDetector.markForCheck(); - } - - /** - * Overrides the parent function so that the foundation can be set with the current - * disabled state. - */ - protected override _setDisabled(value: boolean) { - super._setDisabled(value); - this._radioFoundation.setDisabled(this.disabled); - } }