Skip to content

Commit

Permalink
feat: return root instance if not mounted
Browse files Browse the repository at this point in the history
  • Loading branch information
pimlie authored and karol-f committed Oct 15, 2019
1 parent abe15e6 commit ce2f2b7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/utils/createVueInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ export default function createVueInstance(element, Vue, componentDefinition, pro
// Define the Vue constructor to manage the element
element.__vue_custom_element__ = new Vue(rootElement);
element.__vue_custom_element_props__ = props;
element.getVueInstance = () => element.__vue_custom_element__.$children[0];
element.getVueInstance = () => {
const vueInstance = element.__vue_custom_element__;
return vueInstance.$children.length ? vueInstance.$children[0] : vueInstance;
};

if (options.shadow && options.shadowCss && element.shadowRoot) {
const style = document.createElement('style');
Expand Down

0 comments on commit ce2f2b7

Please sign in to comment.