v-once clashes with v-if
Version
3.0.0-rc.9
Reproduction link
https://github.com/luka-mikec/vue-once-if-issue-demo
Steps to reproduce
- Create a new Vue 3 project (through vue-cli or vite)
- Replace App.vue with: https://github.com/luka-mikec/vue-once-if-issue-demo/blob/master/src/App.vue
- Run
npm run serve
(ornpm run dev
with Vite) and try loading the app in a browser
What is expected?
The resulting webpage should display "a"
What is actually happening?
Error (vue-cli):
ERROR Failed to compile with 1 errors 2:32:19 PM
error in ./src/App.vue?vue&type=template&id=7ba5bd90
Module build failed (from ./node_modules/vue-loader-v16/dist/templateLoader.js):
TypeError: Cannot read property '2' of undefined
at injectProp (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:443:82)
at createChildrenCodegenNode (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:2841:9)
at createCodegenNodeForBranch (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:2797:62)
at Array.<anonymous> (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:2696:38)
at traverseNode (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1681:19)
at traverseChildren (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1624:9)
at traverseNode (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1675:13)
at traverseChildren (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1624:9)
at traverseNode (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1675:13)
at transform (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1566:5)
at Object.baseCompile (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:4115:5)
at Object.compile (/my-project-path/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.js:3033:25)
at doCompileTemplate (/my-project-path/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:580:34)
at Object.compileTemplate (/my-project-path/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:564:16)
at Object.TemplateLoader (/my-project-path/node_modules/vue-loader-v16/dist/templateLoader.js:32:37)
@ ./src/App.vue?vue&type=template&id=7ba5bd90 1:0-319 1:0-319
@ ./src/App.vue
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://192.168.0.126:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
With Vite:
TypeError: Cannot read property '2' of undefined
at injectProp (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:443:82)
at createChildrenCodegenNode (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:2841:9)
at createCodegenNodeForBranch (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:2797:62)
at Array.<anonymous> (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:2696:38)
at traverseNode (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1681:19)
at traverseChildren (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1624:9)
at traverseNode (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1675:13)
at traverseChildren (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1624:9)
at traverseNode (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1675:13)
at transform (/my-project-path/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1566:5)
@yyx990803 The problem reappears when adding a new node with v-else
, regardless of whether v-once
is present in the new node. I updated my example: https://github.com/luka-mikec/vue-once-if-issue-demo/blob/master/src/App.vue
Edit: there is a problem with v-once inside v-for too, I added an example to the same file.
It's indeed failing on the template explorer