Skip to content

Commit 12fcf9a

Browse files
committed
fix(compiler): fix v-for fragment openBlock argument
1 parent 47e984d commit 12fcf9a

File tree

7 files changed

+24
-23
lines changed

7 files changed

+24
-23
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ return function render(_ctx, _cache) {
1515
(_openBlock(), ok
1616
? _createBlock(\\"div\\", { key: 0 }, \\"yes\\")
1717
: _createBlock(_Fragment, { key: 1 }, [\\"no\\"])),
18-
(_openBlock(false), _createBlock(_Fragment, null, _renderList(list, (value, index) => {
18+
(_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (value, index) => {
1919
return (_openBlock(), _createBlock(\\"div\\", null, [
2020
_createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
2121
]))
@@ -37,7 +37,7 @@ return function render(_ctx, _cache) {
3737
(_openBlock(), (_ctx.ok)
3838
? _createBlock(\\"div\\", { key: 0 }, \\"yes\\")
3939
: _createBlock(_Fragment, { key: 1 }, [\\"no\\"])),
40-
(_openBlock(false), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
40+
(_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
4141
return (_openBlock(), _createBlock(\\"div\\", null, [
4242
_createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
4343
]))
@@ -58,7 +58,7 @@ export function render(_ctx, _cache) {
5858
(_openBlock(), (_ctx.ok)
5959
? _createBlock(\\"div\\", { key: 0 }, \\"yes\\")
6060
: _createBlock(_Fragment, { key: 1 }, [\\"no\\"])),
61-
(_openBlock(false), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
61+
(_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
6262
return (_openBlock(), _createBlock(\\"div\\", null, [
6363
_createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
6464
]))

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ return function render(_ctx, _cache) {
229229
const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, toDisplayString: _toDisplayString, createVNode: _createVNode } = _Vue
230230
231231
return (_openBlock(), _createBlock(\\"div\\", null, [
232-
(_openBlock(false), _createBlock(_Fragment, null, _renderList(_ctx.list, (o) => {
232+
(_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (o) => {
233233
return (_openBlock(), _createBlock(\\"p\\", null, [
234234
_createVNode(\\"span\\", null, _toDisplayString(o + 'foo'), 1 /* TEXT */)
235235
]))
@@ -264,7 +264,7 @@ return function render(_ctx, _cache) {
264264
const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, toDisplayString: _toDisplayString, createVNode: _createVNode } = _Vue
265265
266266
return (_openBlock(), _createBlock(\\"div\\", null, [
267-
(_openBlock(false), _createBlock(_Fragment, null, _renderList(_ctx.list, (o) => {
267+
(_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (o) => {
268268
return (_openBlock(), _createBlock(\\"p\\", null, [
269269
_createVNode(\\"span\\", null, _toDisplayString(o), 1 /* TEXT */)
270270
]))
@@ -356,7 +356,7 @@ return function render(_ctx, _cache) {
356356
const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
357357
358358
return (_openBlock(), _createBlock(\\"div\\", null, [
359-
(_openBlock(false), _createBlock(_Fragment, null, _renderList(list, (i) => {
359+
(_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (i) => {
360360
return (_openBlock(), _createBlock(\\"div\\", _hoisted_1, [
361361
_hoisted_2
362362
]))

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ return function render(_ctx, _cache) {
77
with (this) {
88
const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createTextVNode: _createTextVNode } = _Vue
99
10-
return (_openBlock(false), _createBlock(_Fragment, null, _renderList(list, (i) => {
10+
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (i) => {
1111
return (_openBlock(), _createBlock(_Fragment, null, [
1212
_createTextVNode(\\"foo\\")
1313
], 64 /* STABLE_FRAGMENT */))

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

+11-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ return function render(_ctx, _cache) {
77
with (this) {
88
const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
99
10-
return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (item) => {
10+
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
1111
return (_openBlock(), _createBlock(\\"span\\"))
1212
}), 256 /* UNKEYED_FRAGMENT */))
1313
}
@@ -21,7 +21,7 @@ return function render(_ctx, _cache) {
2121
with (this) {
2222
const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
2323
24-
return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (item) => {
24+
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
2525
return (_openBlock(), _createBlock(_Fragment, { key: item }, [
2626
\\"hello\\",
2727
_createVNode(\\"span\\")
@@ -38,7 +38,7 @@ return function render(_ctx, _cache) {
3838
with (this) {
3939
const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
4040
41-
return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (item) => {
41+
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
4242
return (_openBlock(), _createBlock(\\"span\\", { key: item }))
4343
}), 128 /* KEYED_FRAGMENT */))
4444
}
@@ -52,7 +52,7 @@ return function render(_ctx, _cache) {
5252
with (this) {
5353
const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
5454
55-
return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (item, __, index) => {
55+
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item, __, index) => {
5656
return (_openBlock(), _createBlock(\\"span\\"))
5757
}), 256 /* UNKEYED_FRAGMENT */))
5858
}
@@ -66,7 +66,7 @@ return function render(_ctx, _cache) {
6666
with (this) {
6767
const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
6868
69-
return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (_, __, index) => {
69+
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (_, __, index) => {
7070
return (_openBlock(), _createBlock(\\"span\\"))
7171
}), 256 /* UNKEYED_FRAGMENT */))
7272
}
@@ -80,7 +80,7 @@ return function render(_ctx, _cache) {
8080
with (this) {
8181
const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
8282
83-
return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (_, key, index) => {
83+
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (_, key, index) => {
8484
return (_openBlock(), _createBlock(\\"span\\"))
8585
}), 256 /* UNKEYED_FRAGMENT */))
8686
}
@@ -94,7 +94,7 @@ return function render(_ctx, _cache) {
9494
with (this) {
9595
const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
9696
97-
return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (item) => {
97+
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
9898
return (_openBlock(), _createBlock(_Fragment, null, [
9999
\\"hello\\",
100100
_createVNode(\\"span\\")
@@ -111,7 +111,7 @@ return function render(_ctx, _cache) {
111111
with (this) {
112112
const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, renderSlot: _renderSlot } = _Vue
113113
114-
return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (item) => {
114+
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
115115
return _renderSlot($slots, \\"default\\")
116116
}), 256 /* UNKEYED_FRAGMENT */))
117117
}
@@ -125,7 +125,7 @@ return function render(_ctx, _cache) {
125125
with (this) {
126126
const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, renderSlot: _renderSlot } = _Vue
127127
128-
return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (item) => {
128+
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
129129
return _renderSlot($slots, \\"default\\")
130130
}), 256 /* UNKEYED_FRAGMENT */))
131131
}
@@ -141,7 +141,7 @@ return function render(_ctx, _cache) {
141141
142142
const _directive_foo = _resolveDirective(\\"foo\\")
143143
144-
return (_openBlock(false), _createBlock(_Fragment, null, _renderList(list, (i) => {
144+
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (i) => {
145145
return (_openBlock(), _withDirectives(_createBlock(\\"div\\", null, null, 32 /* NEED_PATCH */), [
146146
[_directive_foo]
147147
]))
@@ -173,7 +173,7 @@ return function render(_ctx, _cache) {
173173
with (this) {
174174
const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
175175
176-
return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (item, key, index) => {
176+
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item, key, index) => {
177177
return (_openBlock(), _createBlock(\\"span\\"))
178178
}), 256 /* UNKEYED_FRAGMENT */))
179179
}

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ export const transformFor = createStructuralDirectiveTransform(
5757
? PatchFlags.KEYED_FRAGMENT
5858
: PatchFlags.UNKEYED_FRAGMENT
5959
forNode.codegenNode = createSequenceExpression([
60-
// fragment blocks disable tracking since they always diff their children
61-
createCallExpression(helper(OPEN_BLOCK), [`false`]),
60+
// v-for fragment blocks disable tracking since they always diff their
61+
// children
62+
createCallExpression(helper(OPEN_BLOCK), [`true`]),
6263
createCallExpression(helper(CREATE_BLOCK), [
6364
helper(FRAGMENT),
6465
`null`,

packages/compiler-ssr/__tests__/ssrComponent.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ describe('ssr: components', () => {
231231
return [
232232
(_openBlock(), (_ctx.ok)
233233
? _createBlock(\\"div\\", { key: 0 }, [
234-
(_openBlock(false), _createBlock(_Fragment, null, _renderList(list, (i) => {
234+
(_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (i) => {
235235
return (_openBlock(), _createBlock(\\"span\\"))
236236
}), 256 /* UNKEYED_FRAGMENT */))
237237
])
@@ -254,7 +254,7 @@ describe('ssr: components', () => {
254254
return [
255255
(_openBlock(), ok
256256
? _createBlock(\\"div\\", { key: 0 }, [
257-
(_openBlock(false), _createBlock(_Fragment, null, _renderList(_ctx.list, (i) => {
257+
(_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (i) => {
258258
return (_openBlock(), _createBlock(\\"span\\"))
259259
}), 256 /* UNKEYED_FRAGMENT */))
260260
])

packages/runtime-core/src/vnode.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ let currentBlock: VNode[] | null = null
134134
//
135135
// disableTracking is true when creating a fragment block, since a fragment
136136
// always diffs its children.
137-
export function openBlock(disableTracking?: boolean) {
137+
export function openBlock(disableTracking = false) {
138138
blockStack.push((currentBlock = disableTracking ? null : []))
139139
}
140140

0 commit comments

Comments
 (0)