karol-f / vue-custom-element

Vue Custom Element - Web Components' Custom Elements for Vue.js
https://karol-f.github.io/vue-custom-element/
MIT License
1.97k stars 187 forks source link

Cannot read property 'create' of undefined #187

Closed jloracudris closed 4 years ago

jloracudris commented 4 years ago

Hey Great work with this lib, can you help me with this bug:

I am trying to have two bundles, both of them have the import vueCustomElement from 'vue-custom-element' and also import 'document-register-element'

I am using 3.2.10 version.

this is the stack trace of the error: Uncaught TypeError: Cannot read property 'create' of undefined at new t. (document-register-element.js:2) at e.$d (vue-custom-element.esm.js:37) at new e (vue-custom-element.esm.js:82) at HTMLDocument.A.E.createElement (document-register-element.js:2) at Object.createElement$1 [as createElement] (vue.esm.js?efeb:5690) at createElm (vue.esm.js?efeb:5954) at createChildren (vue.esm.js?efeb:6058) at createElm (vue.esm.js?efeb:5959) at VueComponent.patch [as patch] (vue.esm.js?efeb:6482) at VueComponent.Vue._update (vue.esm.js?efeb:3948)

karol-f commented 4 years ago

Sorry for the late response.

Probably You are trying to install vue-custom-element in both bundles (by using Vue.use(VueCustomElement)) but I'm not sure.

Can You please prepare CodeSandbox (e.g. fork https://codesandbox.io/s/1zw738rn54?fontsize=14&hidenavigation=1&theme=dark) and show an example?

troovers commented 4 years ago

I'm currently experiencing the same issue. I've created a javascript library for clients of mine to implement on their site. Clients can place custom element tags on their site, which are then populated with content from my application using this library. This is working for most of my clients, however one of them is seeing the same error described above. It might be because that site references a library which also uses vue-custom-element. Is their a way to detect this?

karol-f commented 4 years ago

I would gladly look at it, can You @troovers prepare CodeSandbox (e.g. fork https://codesandbox.io/s/1zw738rn54?fontsize=14&hidenavigation=1&theme=dark) example?

troovers commented 4 years ago

Thanks. I've updated the forked example you sent. However, you won't experience the issue my client has, since I'm unable to reproduce that either.

jloracudris commented 4 years ago

Hey Guys sorry for the late response, i was able to go around the issue, it was a version issue of the document-register-element lib, but i think this should be taking into consideration so it doesnt happen with other versions: Versions where it works:

@karol-f the answer is yes i installed vue-custom-element in both bundles and that seems to work, the issue seems to be with lower versions of document-register-element

karol-f commented 4 years ago

Ach, ok, it's good that it's working!

jloracudris commented 4 years ago

It was a painfull bug to catch tho jeje great work @karol-f