Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v-once clashes with v-if #2035

Closed
luka-mikec opened this issue Sep 2, 2020 · 3 comments · Fixed by #2182
Closed

v-once clashes with v-if #2035

luka-mikec opened this issue Sep 2, 2020 · 3 comments · Fixed by #2182
Labels
has PR A pull request has already been submitted to solve the issue 🐞 bug Something isn't working

Comments

@luka-mikec
Copy link

Version

3.0.0-rc.9

Reproduction link

https://github.com/luka-mikec/vue-once-if-issue-demo

Steps to reproduce

  1. Create a new Vue 3 project (through vue-cli or vite)
  2. Replace App.vue with: https://github.com/luka-mikec/vue-once-if-issue-demo/blob/master/src/App.vue
  3. Run npm run serve (or npm 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)
@luka-mikec
Copy link
Author

luka-mikec commented Sep 3, 2020

@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.

@luka-mikec
Copy link
Author

@yyx990803 the problem is present in v3.0 too

@posva posva reopened this Sep 20, 2020
@posva
Copy link
Member

posva commented Sep 20, 2020

It's indeed failing on the template explorer

@posva posva added 🐞 bug Something isn't working has PR A pull request has already been submitted to solve the issue labels Sep 29, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Nov 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has PR A pull request has already been submitted to solve the issue 🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants