Ref pr #8075 Add new option allowHtml (default false) to allow HTML in tooltip.
this.options.tipText = this.options.tipText || this.$element.attr('title');
this.template = this.options.template ? $(this.options.template) : this._buildTemplate(elemId);
- this.template.appendTo(document.body)
+ if (this.options.allowHtml) {
+ this.template.appendTo(document.body)
+ .html(this.options.tipText)
+ .hide();
+ } else {
+ this.template.appendTo(document.body)
.text(this.options.tipText)
.hide();
+ }
this.$element.attr({
'title': '',
* @option
* @example 12
*/
- hOffset: 12
+ hOffset: 12,
+ /**
+ * Allow HTML in tooltip. Warning: If you are loading user-generated content into tooltips,
+ * allowing HTML may open yourself up to XSS attacks.
+ * @option
+ * @example false
+ */
+ allowHtml: false
};
/**