Skip to content

Commit c7d1c17

Browse files
codef0rmerzmmalerba
authored andcommitted
fix(button): reuse _getHostElement() to avoid redundant elementRef.nativeElement calls (#2625)
1 parent e2ad3a0 commit c7d1c17

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lib/button/button.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class MdButton {
8282

8383
_setElementColor(color: string, isAdd: boolean) {
8484
if (color != null && color != '') {
85-
this._renderer.setElementClass(this._elementRef.nativeElement, `md-${color}`, isAdd);
85+
this._renderer.setElementClass(this._getHostElement(), `md-${color}`, isAdd);
8686
}
8787
}
8888

@@ -96,15 +96,15 @@ export class MdButton {
9696

9797
/** Focuses the button. */
9898
focus(): void {
99-
this._renderer.invokeElementMethod(this._elementRef.nativeElement, 'focus');
99+
this._renderer.invokeElementMethod(this._getHostElement(), 'focus');
100100
}
101101

102102
_getHostElement() {
103103
return this._elementRef.nativeElement;
104104
}
105105

106106
_isRoundButton() {
107-
const el = this._elementRef.nativeElement;
107+
const el = this._getHostElement();
108108
return el.hasAttribute('md-icon-button') ||
109109
el.hasAttribute('md-fab') ||
110110
el.hasAttribute('md-mini-fab');

0 commit comments

Comments
 (0)