Skip to content

Commit 0e4dfdc

Browse files
committed
address comments
1 parent e1a3618 commit 0e4dfdc

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/lib/radio/radio.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ describe('MdRadio', () => {
229229
});
230230

231231
it('should not show ripples on disabled radio buttons', () => {
232-
radioInstances[0].disabled = true;
232+
testComponent.isFirstDisabled = true;
233233
fixture.detectChanges();
234234

235235
dispatchFakeEvent(radioLabelElements[0], 'mousedown');
@@ -238,7 +238,7 @@ describe('MdRadio', () => {
238238
expect(radioNativeElements[0].querySelectorAll('.mat-ripple-element').length)
239239
.toBe(0, 'Expected a disabled radio button to not show ripples');
240240

241-
radioInstances[0].disabled = false;
241+
testComponent.isFirstDisabled = false;
242242
fixture.detectChanges();
243243

244244
dispatchFakeEvent(radioLabelElements[0], 'mousedown');

src/lib/radio/radio.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,7 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase
146146

147147
set labelPosition(v) {
148148
this._labelPosition = (v == 'before') ? 'before' : 'after';
149-
if (this._radios) {
150-
this._radios.forEach(radio => radio._groupValueChanged());
151-
}
149+
this._markRadiosForCheck();
152150
}
153151

154152
/** Value of the radio button. */
@@ -186,7 +184,7 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase
186184
this._disabled = value;
187185
if (this._radios) {
188186
// Update radios disabled state
189-
this._radios.forEach((r) => r._groupValueChanged());
187+
this._radios.forEach((r) => r._markForCheck());
190188
}
191189
}
192190

@@ -249,6 +247,12 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase
249247
}
250248
}
251249

250+
_markRadiosForCheck() {
251+
if (this._radios) {
252+
this._radios.forEach(radio => radio._markForCheck());
253+
}
254+
}
255+
252256
/**
253257
* Sets the model value. Implemented as part of ControlValueAccessor.
254258
* @param value
@@ -403,8 +407,6 @@ export class MdRadioButton implements OnInit, AfterViewInit, OnDestroy {
403407
}
404408
set disabled(value: boolean) {
405409
this._disabled = coerceBooleanProperty(value);
406-
// Update rippleDisabled
407-
this._changeDetector.markForCheck();
408410
}
409411

410412
/**
@@ -466,7 +468,12 @@ export class MdRadioButton implements OnInit, AfterViewInit, OnDestroy {
466468
this._focusOriginMonitor.focusVia(this._inputElement.nativeElement, this._renderer, 'keyboard');
467469
}
468470

469-
_groupValueChanged() {
471+
/**
472+
* Marks the radio button as needing checking for change detection.
473+
* This method is exposed because the parent radio group will directly
474+
* update bound properties of the radio button.
475+
*/
476+
_markForCheck() {
470477
// When group value changes, the button will not be notified. Use `markForCheck` to explicit
471478
// update radio button's status
472479
this._changeDetector.markForCheck();

0 commit comments

Comments
 (0)