Skip to content

Commit e5916e4

Browse files
committed
Better to delete if (this.selectionList.disabled) {...} part
1 parent c895aba commit e5916e4

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/lib/list/list-option.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const FOCUSED_STYLE: string = 'mat-list-item-focus';
4646
'class': 'mat-list-item mat-list-option',
4747
'(focus)': '_handleFocus()',
4848
'(blur)': '_handleBlur()',
49-
'(click)': 'toggle()',
49+
'(click)': '_handleClick()',
5050
'tabindex': '-1',
5151
'[attr.aria-selected]': 'selected.toString()',
5252
'[attr.aria-disabled]': 'disabled.toString()',
@@ -125,11 +125,9 @@ export class MdListOption implements AfterContentInit, OnDestroy, Focusable {
125125
}
126126

127127
toggle(): void {
128-
if (!this._disabled) {
129-
this.selected = !this.selected;
130-
this.selectionList.selectedOptions.toggle(this);
131-
this._changeDetector.markForCheck();
132-
}
128+
this.selected = !this.selected;
129+
this.selectionList.selectedOptions.toggle(this);
130+
this._changeDetector.markForCheck();
133131
}
134132

135133
/** Allows for programmatic focusing of the option. */
@@ -143,6 +141,12 @@ export class MdListOption implements AfterContentInit, OnDestroy, Focusable {
143141
return !this.disableRipple && !this.selectionList.disableRipple;
144142
}
145143

144+
_handleClick() {
145+
if (!this._disabled) {
146+
this.toggle();
147+
}
148+
}
149+
146150
_handleFocus() {
147151
this._hasFocus = true;
148152
this._renderer.addClass(this._element.nativeElement, FOCUSED_STYLE);

0 commit comments

Comments
 (0)