Skip to content

Commit 0386bdd

Browse files
committed
addressed comments
1 parent f96fb0d commit 0386bdd

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

src/lib/checkbox/checkbox.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
(blur)="_onInputBlur()"
1515
(change)="_onInteractionEvent($event)"
1616
(click)="_onInputClick($event)">
17-
<div md-ripple *ngIf="isRippleEnabled()" class="md-checkbox-ripple"
17+
<div md-ripple *ngIf="!disableRipple" class="md-checkbox-ripple"
1818
[md-ripple-trigger]="getHostElement()"
1919
[md-ripple-centered]="true"
2020
[md-ripple-speed-factor]="0.3"

src/lib/checkbox/checkbox.spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,14 +488,14 @@ describe('MdCheckbox', () => {
488488
testComponent.disableRipple = true;
489489
fixture.detectChanges();
490490

491-
expect(checkboxNativeElement.querySelectorAll('[md-ripple]').length).toBe(0,
492-
'Expect no [md-ripple] in checkbox');
491+
expect(checkboxNativeElement.querySelectorAll('[md-ripple]').length)
492+
.toBe(0, 'Expect no [md-ripple] in checkbox');
493493

494494
testComponent.disableRipple = false;
495495
fixture.detectChanges();
496496

497-
expect(checkboxNativeElement.querySelectorAll('[md-ripple]').length).toBe(1,
498-
'Expect [md-ripple] in checkbox');
497+
expect(checkboxNativeElement.querySelectorAll('[md-ripple]').length)
498+
.toBe(1, 'Expect [md-ripple] in checkbox');
499499
}));
500500
});
501501

@@ -612,7 +612,10 @@ class MultipleCheckboxes { }
612612
/** Simple test component with tabIndex */
613613
@Component({
614614
template: `
615-
<md-checkbox [tabindex]="customTabIndex" [disabled]="isDisabled" [disableRipple]="disableRipple">
615+
<md-checkbox
616+
[tabindex]="customTabIndex"
617+
[disabled]="isDisabled"
618+
[disableRipple]="disableRipple">
616619
</md-checkbox>`,
617620
})
618621
class CheckboxWithTabIndex {

src/lib/checkbox/checkbox.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from '@angular/core';
1414
import {CommonModule} from '@angular/common';
1515
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';
16-
import {BooleanFieldValue, MdRippleModule} from '../core';
16+
import {MdRippleModule, coerceBooleanProperty} from '../core';
1717

1818
/**
1919
* Monotonically increasing integer used to auto-generate unique ids for checkbox components.
@@ -90,15 +90,24 @@ export class MdCheckbox implements ControlValueAccessor {
9090
@Input() id: string = `md-checkbox-${++nextId}`;
9191

9292
/** Whether the ripple effect on click should be disabled. */
93-
@Input() @BooleanFieldValue() disableRipple: boolean = false;
93+
private _disableRipple: boolean = false;
94+
95+
@Input()
96+
get disableRipple() { return this._disableRipple; }
97+
set disableRipple(v) { this._disableRipple = coerceBooleanProperty(v); }
9498

9599
/** ID to be applied to the `input` element */
96100
get inputId(): string {
97101
return `input-${this.id}`;
98102
}
99103

100104
/** Whether the checkbox is required or not. */
101-
@Input() @BooleanFieldValue() required: boolean = false;
105+
private _required: boolean;
106+
107+
/** Whether the checkbox is required or not. */
108+
@Input()
109+
get required(): boolean { return this._required; }
110+
set required(value) { this._required = coerceBooleanProperty(value); }
102111

103112
/** Whether or not the checkbox should come before or after the label. */
104113
@Input() align: 'start' | 'end' = 'start';
@@ -341,10 +350,6 @@ export class MdCheckbox implements ControlValueAccessor {
341350
getHostElement() {
342351
return this._elementRef.nativeElement;
343352
}
344-
345-
isRippleEnabled() {
346-
return !this.disableRipple;
347-
}
348353
}
349354

350355

0 commit comments

Comments
 (0)