Skip to content

Commit

Permalink
fix(tooltip, popover): check document.body instead of document fo…
Browse files Browse the repository at this point in the history
…r IE11 support (fixes #4074) (#4075)

* fix(tooltip, popover): check `document.body` instead of `document` for IE11 support (fixes #4074)

* lint
  • Loading branch information
tmorehouse authored and jacobmllr95 committed Sep 11, 2019
1 parent de6e229 commit 1eda4fe
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/components/tooltip/helpers/bv-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
isDisabled,
isVisible,
closest,
contains,
select,
getById,
hasClass,
Expand Down Expand Up @@ -204,7 +205,7 @@ export const BVTooltip = /*#__PURE__*/ Vue.extend({

this.$nextTick(() => {
const target = this.getTarget()
if (target && document.contains(target)) {
if (target && contains(document.body, target)) {
// Copy the parent's scoped style attribute
this.scopeId = getScopId(this.$parent)
// Set up all trigger handlers and listeners
Expand Down Expand Up @@ -353,7 +354,12 @@ export const BVTooltip = /*#__PURE__*/ Vue.extend({
// Show the tooltip
const target = this.getTarget()

if (!target || !document.body.contains(target) || !isVisible(target) || this.dropdownOpen()) {
if (
!target ||
!contains(document.body, target) ||
!isVisible(target) ||
this.dropdownOpen()
) {
// If trigger element isn't in the DOM or is not visible, or is on an open dropdown toggle
return
}
Expand Down Expand Up @@ -783,13 +789,13 @@ export const BVTooltip = /*#__PURE__*/ Vue.extend({
/* istanbul ignore next */
if (
// From tip to target
(tip && tip.contains(evtTarget) && target.contains(relatedTarget)) ||
(tip && contains(tip, evtTarget) && contains(target, relatedTarget)) ||
// From target to tip
(tip && target.contains(evtTarget) && tip.contains(relatedTarget)) ||
(tip && contains(target, evtTarget) && contains(tip, relatedTarget)) ||
// Within tip
(tip && tip.contains(evtTarget) && tip.contains(relatedTarget)) ||
(tip && contains(tip, evtTarget) && contains(tip, relatedTarget)) ||
// Within target
(target.contains(evtTarget) && target.contains(relatedTarget))
(contains(target, evtTarget) && contains(target, relatedTarget))
) {
// If focus/hover moves within `tip` and `target`, don't trigger a leave
return
Expand Down

0 comments on commit 1eda4fe

Please sign in to comment.