jquery-powertip
jquery-powertip copied to clipboard
Allow escaping content
I've a case where user input is used as tooltip. In the end I needed to overwrite the getTooltipContent
function and changed return content
to return escapeHTML(content)
(escapeHTML
exists already in my case). Would be nice if a simple option could be added.
Properly escaping HTML in all scenarios can actually be tricky. See: jQuery's text()
documentation
Due to variations in the HTML parsers in different browsers, the text returned may vary in newlines and other white space.
So I think that any HTML entities logic would be outside the scope of a humble little tooltip plugin.
However, it might make sense to provide an option to use .text()
instead of .html()
like it is doing today. I'm not sure how best to surface that option though.
Probably a simple event/jhook in the getTooltipContent
function? That way it'd be possible to easily modify the acctual content of the tooltip (eg escaping it, but also change other things).