Skip to content

Instantly share code, notes, and snippets.

@xtrasmal
Created May 30, 2017 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xtrasmal/e53b2a8f77353e423cd87d46f267610d to your computer and use it in GitHub Desktop.
Save xtrasmal/e53b2a8f77353e423cd87d46f267610d to your computer and use it in GitHub Desktop.
Vue $mountIf
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