From 3342ab199e2fee1af0402a8365d91e7da5fabcc5 Mon Sep 17 00:00:00 2001 From: codef0rmer Date: Fri, 13 Jan 2017 15:42:09 +0530 Subject: [PATCH] fix(button): reuse _getHostElement() to avoid redundant elementRef.nativeElement calls --- src/lib/button/button.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/button/button.ts b/src/lib/button/button.ts index 91600e588f04..ea6300e2f3ab 100644 --- a/src/lib/button/button.ts +++ b/src/lib/button/button.ts @@ -82,7 +82,7 @@ export class MdButton { _setElementColor(color: string, isAdd: boolean) { if (color != null && color != '') { - this._renderer.setElementClass(this._elementRef.nativeElement, `md-${color}`, isAdd); + this._renderer.setElementClass(this._getHostElement(), `md-${color}`, isAdd); } } @@ -96,7 +96,7 @@ export class MdButton { /** Focuses the button. */ focus(): void { - this._renderer.invokeElementMethod(this._elementRef.nativeElement, 'focus'); + this._renderer.invokeElementMethod(this._getHostElement(), 'focus'); } _getHostElement() { @@ -104,7 +104,7 @@ export class MdButton { } _isRoundButton() { - const el = this._elementRef.nativeElement; + const el = this._getHostElement(); return el.hasAttribute('md-icon-button') || el.hasAttribute('md-fab') || el.hasAttribute('md-mini-fab');