Skip to content

Commit f6d1078

Browse files
authored
fix(tooltip): ensure tooltip never passes undefined message to (angular#7018)
AriaDescriber
1 parent 50a6bb7 commit f6d1078

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/lib/tooltip/tooltip.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,15 @@ export class MdTooltip implements OnDestroy {
142142
/** The default delay in ms before hiding the tooltip after hide is called */
143143
@Input('mdTooltipHideDelay') hideDelay = 0;
144144

145-
private _message: string;
145+
private _message = '';
146146

147147
/** The message to be displayed in the tooltip */
148148
@Input('mdTooltip') get message() { return this._message; }
149149
set message(value: string) {
150-
if (this._message) {
151-
this._ariaDescriber.removeDescription(this._elementRef.nativeElement, this._message);
152-
}
150+
this._ariaDescriber.removeDescription(this._elementRef.nativeElement, this._message);
153151

154152
// If the message is not a string (e.g. number), convert it to a string and trim it.
155-
this._message = value ? `${value}`.trim() : '';
153+
this._message = value ? value.trim() : '';
156154
this._updateTooltipMessage();
157155
this._ariaDescriber.describe(this._elementRef.nativeElement, this.message);
158156
}

0 commit comments

Comments
 (0)