From 0d77644fc4de0865eebba1ffe04825267df3b8f3 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Tue, 16 Dec 2014 16:40:54 -0800 Subject: throw error when trying to show tooltip on :hidden element --- js/tooltip.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'js/tooltip.js') diff --git a/js/tooltip.js b/js/tooltip.js index ced0e9282..c787c6820 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -293,6 +293,14 @@ Tooltip.prototype['destroy'] = function () { * and replace with external lib */ Tooltip.prototype['show'] = function () { + // jQuery's :hidden gives false positives for SVG elements + // See https://github.com/jquery/jquery/pull/939 + // Since this hiddenness check is just a nicety anyway, simply assume SVGs are always visible. + var isHidden = $(this.element).is(':hidden') && !(window.SVGElement && this.element instanceof window.SVGElement) + if (isHidden) { + throw new Error('Can\'t show a tooltip/popover on a hidden element') + } + var showEvent = $.Event(this.getEventObject().SHOW) if (this.isWithContent() && this._isEnabled) { -- cgit v1.2.3