jquery-powertip icon indicating copy to clipboard operation
jquery-powertip copied to clipboard

Allow escaping content

Open JN-Jones opened this issue 9 years ago • 2 comments

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.

JN-Jones avatar May 04 '15 14:05 JN-Jones

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.

stevenbenner avatar May 05 '15 05:05 stevenbenner

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).

JN-Jones avatar May 05 '15 10:05 JN-Jones