Skip to content

Commit 214bc7b

Browse files
mhansenwagnermaciel
authored andcommitted
fix(material/tooltip): convert message to string (#20685)
This ensures that the Closure Compiler doesn't optimise out the format-string stringification. I'm trying to maintain the runtime API of this code in the face of type-based optimisations. Fixes #20684 (cherry picked from commit d9359c4)
1 parent 6318389 commit 214bc7b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/material/tooltip/tooltip.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
209209
this._ariaDescriber.removeDescription(this._elementRef.nativeElement, this._message);
210210

211211
// If the message is not a string (e.g. number), convert it to a string and trim it.
212-
this._message = value != null ? `${value}`.trim() : '';
212+
// Must convert with `String(value)`, not `${value}`, otherwise Closure Compiler optimises
213+
// away the string-conversion: https://github.com/angular/components/issues/20684
214+
this._message = value != null ? String(value).trim() : '';
213215

214216
if (!this._message && this._isTooltipVisible()) {
215217
this.hide(0);

0 commit comments

Comments
 (0)