aboutsummaryrefslogtreecommitdiff
path: root/js/tooltip.js
diff options
context:
space:
mode:
authorChris Rebert <[email protected]>2014-12-16 16:40:54 -0800
committerChris Rebert <[email protected]>2015-04-23 17:14:45 -0700
commit0d77644fc4de0865eebba1ffe04825267df3b8f3 (patch)
tree76e07fdf145fcd0e823df1ba45369a2159825c95 /js/tooltip.js
parentcfcc597c85cd354fda8f6f34005d7542d11236c0 (diff)
downloadbootstrap-0d77644fc4de0865eebba1ffe04825267df3b8f3.tar.xz
bootstrap-0d77644fc4de0865eebba1ffe04825267df3b8f3.zip
throw error when trying to show tooltip on :hidden element
Diffstat (limited to 'js/tooltip.js')
-rw-r--r--js/tooltip.js8
1 files changed, 8 insertions, 0 deletions
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) {