Skip to content

Commit a1da9c2

Browse files
committed
fix(compiler-core): assign patchFlag for template v-if fragment
fix #850
1 parent 3b282e7 commit a1da9c2

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

packages/compiler-core/__tests__/__snapshots__/compile.spec.ts.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ return function render(_ctx, _cache) {
1616
? (_openBlock(), _createBlock(\\"div\\", { key: 0 }, \\"yes\\"))
1717
: (_openBlock(), _createBlock(_Fragment, { key: 1 }, [
1818
_createTextVNode(\\"no\\")
19-
])),
19+
], 64 /* STABLE_FRAGMENT */)),
2020
(_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (value, index) => {
2121
return (_openBlock(), _createBlock(\\"div\\", null, [
2222
_createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
@@ -40,7 +40,7 @@ return function render(_ctx, _cache) {
4040
? (_openBlock(), _createBlock(\\"div\\", { key: 0 }, \\"yes\\"))
4141
: (_openBlock(), _createBlock(_Fragment, { key: 1 }, [
4242
_createTextVNode(\\"no\\")
43-
])),
43+
], 64 /* STABLE_FRAGMENT */)),
4444
(_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
4545
return (_openBlock(), _createBlock(\\"div\\", null, [
4646
_createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
@@ -63,7 +63,7 @@ export function render(_ctx, _cache) {
6363
? (_openBlock(), _createBlock(\\"div\\", { key: 0 }, \\"yes\\"))
6464
: (_openBlock(), _createBlock(_Fragment, { key: 1 }, [
6565
_createTextVNode(\\"no\\")
66-
])),
66+
], 64 /* STABLE_FRAGMENT */)),
6767
(_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
6868
return (_openBlock(), _createBlock(\\"div\\", null, [
6969
_createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)

packages/compiler-core/__tests__/transforms/__snapshots__/vIf.spec.ts.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ return function render(_ctx, _cache) {
2626
_createVNode(\\"div\\"),
2727
\\"hello\\",
2828
_createVNode(\\"p\\")
29-
]))
29+
], 64 /* STABLE_FRAGMENT */))
3030
: _createCommentVNode(\\"v-if\\", true)
3131
}
3232
}"
@@ -71,7 +71,7 @@ return function render(_ctx, _cache) {
7171
? (_openBlock(), _createBlock(\\"div\\", { key: 0 }))
7272
: orNot
7373
? (_openBlock(), _createBlock(\\"p\\", { key: 1 }))
74-
: (_openBlock(), _createBlock(_Fragment, { key: 2 }, [\\"fine\\"]))
74+
: (_openBlock(), _createBlock(_Fragment, { key: 2 }, [\\"fine\\"], 64 /* STABLE_FRAGMENT */))
7575
}
7676
}"
7777
`;

packages/compiler-core/src/transforms/vIf.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
OPEN_BLOCK
3030
} from '../runtimeHelpers'
3131
import { injectProp } from '../utils'
32+
import { PatchFlags, PatchFlagNames } from '@vue/shared'
3233

3334
export const transformIf = createStructuralDirectiveTransform(
3435
/^(if|else|else-if)$/,
@@ -197,7 +198,9 @@ function createChildrenCodegenNode(
197198
helper(FRAGMENT),
198199
createObjectExpression([keyProperty]),
199200
children,
200-
undefined,
201+
`${PatchFlags.STABLE_FRAGMENT} /* ${
202+
PatchFlagNames[PatchFlags.STABLE_FRAGMENT]
203+
} */`,
201204
undefined,
202205
undefined,
203206
true,

0 commit comments

Comments
 (0)