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

feat(compiler-core): remove repeat key #630

Merged
merged 3 commits into from
Jan 20, 2020

Conversation

soouup
Copy link
Contributor

@soouup soouup commented Jan 16, 2020

Remove the repeat key in v-if when you set key property directly.

Template:

<div>
  <div v-if="xxx" key="2"></div>
</div>

Before:

import { openBlock, createVNode, createBlock, createCommentVNode } from "vue"

export function render() {
  const _ctx = this
  return (openBlock(), createBlock("div", null, [
    (openBlock(), (_ctx.xxx)
      ? createBlock("div", {
          // this key is redundant
          key: 0,
          key: "2"
        })
      : createCommentVNode("v-if", true))
  ]))
}

After:

import { openBlock, createVNode, createBlock, createCommentVNode } from "vue"

export function render() {
  const _ctx = this
  return (openBlock(), createBlock("div", null, [
    (openBlock(), (_ctx.xxx)
      ? createBlock("div", { key: "2" })
      : createCommentVNode("v-if", true))
  ]))
}

@yyx990803
Copy link
Member

Can you add a test case for this? Can be in vIf.spec.ts and simply assert the snapshot.

@yyx990803 yyx990803 merged commit aca2c2a into vuejs:master Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants