1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-25 21:09:06 +02:00

throw error when trying to show tooltip on :hidden element

This commit is contained in:
Chris Rebert
2014-12-16 16:40:54 -08:00
parent cfcc597c85
commit 0d77644fc4
3 changed files with 68 additions and 34 deletions

View File

@@ -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) {