Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(b-tooltip): Updated tooltip to work under shadowDOM#6997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
rasicoc wants to merge2 commits intobootstrap-vue:dev
base:dev
Choose a base branch
Loading
fromrasicoc:fix-tooltip-web-component-compatibility
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletionssrc/components/tooltip/helpers/bv-tooltip.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,8 +29,10 @@ import {
contains,
getAttr,
getById,
getShadowRootOrRoot,
hasAttr,
hasClass,
isConnectedToDOM,
isDisabled,
isElement,
isVisible,
Expand DownExpand Up@@ -262,7 +264,7 @@ export const BVTooltip = /*#__PURE__*/ Vue.extend({

this.$nextTick(() => {
const target = this.getTarget()
if (target &&contains(document.body,target)) {
if (target &&(target.isConnected || isConnectedToDOM(target))) {
// Copy the parent's scoped style attribute
this.scopeId = getScopeId(this.$parent)
// Set up all trigger handlers and listeners
Expand DownExpand Up@@ -420,7 +422,7 @@ export const BVTooltip = /*#__PURE__*/ Vue.extend({
const target = this.getTarget()
if (
!target ||
!contains(document.body,target) ||
!isConnectedToDOM(target) ||
!isVisible(target) ||
this.dropdownOpen() ||
((isUndefinedOrNull(this.title) || this.title === '') &&
Expand DownExpand Up@@ -567,8 +569,9 @@ export const BVTooltip = /*#__PURE__*/ Vue.extend({
getContainer() {
// Handle case where container may be a component ref
const container = this.container ? this.container.$el || this.container : false
const body = document.body
const target = this.getTarget()
const body = getShadowRootOrRoot(target)

// If we are in a modal, we append to the modal, If we
// are in a sidebar, we append to the sidebar, else append
// to body, unless a container is specified
Expand Down
22 changes: 19 additions & 3 deletionssrc/utils/dom.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -83,9 +83,8 @@ export const isActiveElement = el => isElement(el) && el === getActiveElement()

// Determine if an HTML element is visible - Faster than CSS check
export const isVisible = el => {
if (!isElement(el) || !el.parentNode || !contains(DOCUMENT.body, el)) {
// Note this can fail for shadow dom elements since they
// are not a direct descendant of document.body
if (!isElement(el) || !el.parentNode || !isConnectedToDOM(el)) {
// Fail for IE11 Shadow DOM. Fixed for all other Browsers
return false
}
if (getStyle(el, 'display') === 'none') {
Expand All@@ -100,6 +99,23 @@ export const isVisible = el => {
return !!(bcr && bcr.height > 0 && bcr.width > 0)
}

// used to grab either the shadow root in a web component or the main document body
export const getShadowRootOrRoot = el => {
if (el.getRootNode == null) {
return DOCUMENT.body
}
const root = el.getRootNode()
if (root.nodeName === '#document') {
return root.body
}
return root
}

export const isConnectedToDOM = el => {
// If node.isConnected undefined then fallback to IE11 compliant check
return el.isConnected == null ? contains(DOCUMENT.body, el) : el.isConnected
}

// Determine if an element is disabled
export const isDisabled = el =>
!isElement(el) || el.disabled || hasAttr(el, 'disabled') || hasClass(el, 'disabled')
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp