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

:key placed in <template> with one element is not used #1907

Closed
ota-meshi opened this issue Aug 20, 2020 · 0 comments · Fixed by #1910
Closed

:key placed in <template> with one element is not used #1907

ota-meshi opened this issue Aug 20, 2020 · 0 comments · Fixed by #1910

Comments

@ota-meshi
Copy link
Member

Version

3.0.0-rc.6

Reproduction link

DEMO on Vue3 template explorer

Steps to reproduce

Check the compilation results of Case2 and Case4.

<div>
  <!-- Case1 -- The key is attached to _Fragment.-->
  <template v-for="item in list" :key="item.id1">
    <MyButton :foo="item">One</MyButton>
    <MyButton :foo="item">Two</MyButton>
  </template>
  <!-- Case2 -- The key is not attached to _Fragment. -->
  <template v-for="item in list" :key="item.id2">
    <MyButton :foo="item">One</MyButton>
  </template>
  <!-- Case3 -- The key is attached to div. -->
  <div v-for="item in list" :key="item.id3">
    <MyButton :foo="item">One</MyButton>
  </div>
  <!-- Case4 -- The key is not attached to _Fragment. -->
  <template v-for="item in list" :key="item.id4">
    <div>
      <MyButton :foo="item">One</MyButton>
    </div>
  </template>
</div>

What is expected?

I expected {key: item.id2} and {key: item.id4} to be attached somewhere.

What is actually happening?

{key: item.id2} and {key: item.id4} are not attached anywhere.


Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant