fix(compiler-core): assign patchFlag for template v-if fragment

fix #850
This commit is contained in:
Evan You 2020-03-17 11:36:56 -04:00
parent 3b282e7e3c
commit a1da9c28a0
3 changed files with 9 additions and 6 deletions

View File

@ -16,7 +16,7 @@ return function render(_ctx, _cache) {
? (_openBlock(), _createBlock(\\"div\\", { key: 0 }, \\"yes\\")) ? (_openBlock(), _createBlock(\\"div\\", { key: 0 }, \\"yes\\"))
: (_openBlock(), _createBlock(_Fragment, { key: 1 }, [ : (_openBlock(), _createBlock(_Fragment, { key: 1 }, [
_createTextVNode(\\"no\\") _createTextVNode(\\"no\\")
])), ], 64 /* STABLE_FRAGMENT */)),
(_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (value, index) => { (_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (value, index) => {
return (_openBlock(), _createBlock(\\"div\\", null, [ return (_openBlock(), _createBlock(\\"div\\", null, [
_createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */) _createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
@ -40,7 +40,7 @@ return function render(_ctx, _cache) {
? (_openBlock(), _createBlock(\\"div\\", { key: 0 }, \\"yes\\")) ? (_openBlock(), _createBlock(\\"div\\", { key: 0 }, \\"yes\\"))
: (_openBlock(), _createBlock(_Fragment, { key: 1 }, [ : (_openBlock(), _createBlock(_Fragment, { key: 1 }, [
_createTextVNode(\\"no\\") _createTextVNode(\\"no\\")
])), ], 64 /* STABLE_FRAGMENT */)),
(_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => { (_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
return (_openBlock(), _createBlock(\\"div\\", null, [ return (_openBlock(), _createBlock(\\"div\\", null, [
_createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */) _createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
@ -63,7 +63,7 @@ export function render(_ctx, _cache) {
? (_openBlock(), _createBlock(\\"div\\", { key: 0 }, \\"yes\\")) ? (_openBlock(), _createBlock(\\"div\\", { key: 0 }, \\"yes\\"))
: (_openBlock(), _createBlock(_Fragment, { key: 1 }, [ : (_openBlock(), _createBlock(_Fragment, { key: 1 }, [
_createTextVNode(\\"no\\") _createTextVNode(\\"no\\")
])), ], 64 /* STABLE_FRAGMENT */)),
(_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => { (_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
return (_openBlock(), _createBlock(\\"div\\", null, [ return (_openBlock(), _createBlock(\\"div\\", null, [
_createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */) _createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)

View File

@ -26,7 +26,7 @@ return function render(_ctx, _cache) {
_createVNode(\\"div\\"), _createVNode(\\"div\\"),
\\"hello\\", \\"hello\\",
_createVNode(\\"p\\") _createVNode(\\"p\\")
])) ], 64 /* STABLE_FRAGMENT */))
: _createCommentVNode(\\"v-if\\", true) : _createCommentVNode(\\"v-if\\", true)
} }
}" }"
@ -71,7 +71,7 @@ return function render(_ctx, _cache) {
? (_openBlock(), _createBlock(\\"div\\", { key: 0 })) ? (_openBlock(), _createBlock(\\"div\\", { key: 0 }))
: orNot : orNot
? (_openBlock(), _createBlock(\\"p\\", { key: 1 })) ? (_openBlock(), _createBlock(\\"p\\", { key: 1 }))
: (_openBlock(), _createBlock(_Fragment, { key: 2 }, [\\"fine\\"])) : (_openBlock(), _createBlock(_Fragment, { key: 2 }, [\\"fine\\"], 64 /* STABLE_FRAGMENT */))
} }
}" }"
`; `;

View File

@ -29,6 +29,7 @@ import {
OPEN_BLOCK OPEN_BLOCK
} from '../runtimeHelpers' } from '../runtimeHelpers'
import { injectProp } from '../utils' import { injectProp } from '../utils'
import { PatchFlags, PatchFlagNames } from '@vue/shared'
export const transformIf = createStructuralDirectiveTransform( export const transformIf = createStructuralDirectiveTransform(
/^(if|else|else-if)$/, /^(if|else|else-if)$/,
@ -197,7 +198,9 @@ function createChildrenCodegenNode(
helper(FRAGMENT), helper(FRAGMENT),
createObjectExpression([keyProperty]), createObjectExpression([keyProperty]),
children, children,
undefined, `${PatchFlags.STABLE_FRAGMENT} /* ${
PatchFlagNames[PatchFlags.STABLE_FRAGMENT]
} */`,
undefined, undefined,
undefined, undefined,
true, true,