Tooltips do not work on elements inside Shadow DOM
Created by: ericcarino
I'm trying to add a tooltip to a button that resides inside a shadow DOM. Unfortunately, does not work. I traced the problem down to this snippet of code inside bootstrap.js.
Tooltip.prototype.show = function show() {
var _this22 = this;
if ($(this.element).css('display') === 'none') {
throw new Error('Please use show on visible elements');
}
var showEvent = $.Event(this.constructor.Event.SHOW);
if (this.isWithContent() && this._isEnabled) {
if (this._isTransitioning) {
throw new Error('Tooltip is transitioning');
}
$(this.element).trigger(showEvent);
var isInTheDom = $.contains(this.element.ownerDocument.documentElement, this.element);
if (showEvent.isDefaultPrevented() || !isInTheDom) {
return;
}
isInTheDom is false because jquery.contains doesn't find the element, which I assume is because it resides inside the shadow DOM. If I manually set this value to true, the tooltip works perfectly. See my screenshot below.
To access my JSBin example, use the link below. http://jsbin.com/qukeye/2/edit?html,js,output