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

fix(compiler-core): should attach key into fragment if `<template v-f… #1910

Merged

Conversation

underfin
Copy link
Member

…or/>` has normal children

fix #1907

@yyx990803 yyx990803 merged commit 69cfed6 into vuejs:master Aug 20, 2020
@underfin
Copy link
Member Author

It will be hosited key props.I'm try add code to resolve it ...
<template v-for="item in items" :key="item"><span/></template> will be compiled

const _Vue = Vue
const { createVNode: _createVNode } = _Vue

const _hoisted_1 = { key: item }

return function render(_ctx, _cache, $props, $setup, $data, $options) {
  with (_ctx) {
    const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createVNode: _createVNode } = _Vue

    return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
      return (_openBlock(), _createBlock("span", _hoisted_1))
    }), 128 /* KEYED_FRAGMENT */))
  }
}

// Check the console for the AST

@underfin underfin deleted the v-for-template-pass-key-into-fragment branch August 20, 2020 14:40
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.

:key placed in <template> with one element is not used
2 participants