alexjoverm / v-runtime-template

Vue component for compiling templates on the fly using a v-html like API
MIT License
605 stars 70 forks source link

Handle cases where this.$options.methods, .computed, and .components … #45

Closed hunterae closed 5 years ago

hunterae commented 5 years ago

…are not defined

moltar commented 5 years ago

I'm getting this now:

TypeError: Cannot convert undefined or null to object
    at keys (<anonymous>)
moltar commented 5 years ago

Looks like at this line:

      Object.keys(methods).forEach(function (e) {if(typeof this$1.$options.methods[e]==="undefined") { passthrough.methods[e] = methods[e]; }} );

Probably need to do:

      Object.keys(methods || {})

On all objects.

hunterae commented 5 years ago

@moltar , are you saying you're getting that error with the code I submitted in this pull request?

That change shouldn't be necessary as methods is set to {} by default; see https://github.com/alexjoverm/v-runtime-template/blob/9d7469bffe5c040dc6f7953514100e31b0d6e4f1/index.js#L32

moltar commented 5 years ago

Yes, I am getting the error with this PR.

hunterae commented 5 years ago

@moltar , I did not previously rebuild the dist scripts. I did that just now and pushed. Can you see if that fixes the problem for you. Also, if you're still having issues, could you fork this codepen and send me a broken example: https://codepen.io/hunterae/pen/WBrzXL

moltar commented 5 years ago

That does indeed work great. Thanks!

alexjoverm commented 5 years ago

Fixed by 1.7.0