oliverfindl / vue-svg-inline-plugin

Vue plugin for inline replacement of SVG images with actual content of SVG files.
MIT License
33 stars 3 forks source link

Error: Required property is missing! [node.parentNode] #20

Open denisov-k opened 1 year ago

denisov-k commented 1 year ago

Hello everyone!

I have next composition:

   <img v-svg-inline src="@/assets/widget/expand.svg" v-if="!expanded" />
   <img v-svg-inline src="@/assets/widget/collapse.svg" v-else />

After toggle v-if value I have next error in console. err Who can tell me what is the problem?

oliverfindl commented 1 year ago

Hello,

it looks like, Vue somehow removed parent element of your <img> tag, therefore this plugins fails to replace <img> tag with <svg> tag.

https://github.com/oliverfindl/vue-svg-inline-plugin/blob/97be1e3e224b355c9a629cc3677152775215e83e/src/index.js#L353-L357

Please try to wrap your <img> tags with <div> tags, and move your conditions there. If this won't resolve your issue, please provide minimal reproduction repository, so I can investigate further.

Thanks.