underfin / vite-plugin-vue2

Vue2 plugin for Vite
620 stars 83 forks source link

[bug] Template ref for canvas doesn't work when using same name as element #187

Open jclaessens97 opened 2 years ago

jclaessens97 commented 2 years ago

Description

I found out that when using a template ref for a canvas while naming it canvas, that the vue2 compiler doesn't work. It does work with vue3 compiler, and when renaming the ref to for example cv.

I'm not 100% certain that its only with canvas refs or also with other elements.

I also noticed that during compilation the canvas variable was renamed to canvas2, but the original canvas is still referenced in the code, which is then undefined.

Expected outcome

It should just work the same as in vue3 when giving the name canvas it shouldn't be an issue?

Reproduction

https://github.com/jclaessens97/template-ref-repro

go to vue3-lib -> npm run dev -> works go to vue2-lib -> npm run dev -> works go to vue2-lib -> uncomment canvas & comment cv -> crashes