bootstrap-vue
Version:
With more than 85 components, over 45 available plugins, several directives, and 1000+ icons, BootstrapVue provides one of the most comprehensive implementations of the Bootstrap v4 component and grid system available for Vue.js v2.6, complete with extens
41 lines (31 loc) • 696 B
JavaScript
import { isVue3 } from '../vue'
let registry = null
if (isVue3) {
registry = new WeakMap()
}
export const registerElementToInstance = (element, instance) => {
if (!isVue3) {
return
}
registry.set(element, instance)
}
export const removeElementToInstance = element => {
if (!isVue3) {
return
}
registry.delete(element)
}
export const getInstanceFromElement = element => {
if (!isVue3) {
return element.__vue__
}
let currentElement = element
while (currentElement) {
if (registry.has(currentElement)) {
/* istanbul ignore next */
return registry.get(currentElement)
}
currentElement = currentElement.parentNode
}
return null
}