Created
May 30, 2017 19:11
-
-
Save xtrasmal/e53b2a8f77353e423cd87d46f267610d to your computer and use it in GitHub Desktop.
Vue $mountIf
This file contains hidden or 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
const elementIsFound = (element) => {return document.body.contains(document.getElementById(element))}; | |
Vue.prototype.$mountIf = (el, hydrating) => { | |
if(elementIsFound(el)) { | |
el = el && inBrowser ? query(el) : undefined; | |
return mountComponent(this, el, hydrating) | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment