Last active
June 22, 2023 19:30
-
-
Save Mosharush/95c379ff2cf8f8b977b0c12196ea40bd to your computer and use it in GitHub Desktop.
Function to get closest vue instance from DOM element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function getClosestVueInstance (elm) { | |
if (!elm) return; | |
const parentNode = elm.parentNode; | |
const vueInstance = parentNode?.__vue__; | |
return vueInstance ?? getClosestVueInstance(parentNode); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment