Skip to content

Commit

Permalink
fix(runtime-core): openBlock() should not be tracked when block track…
Browse files Browse the repository at this point in the history
…ing is disabled
  • Loading branch information
yyx990803 committed Sep 2, 2020
1 parent 552ad4e commit ad93fa4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion packages/runtime-core/__tests__/vnode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '../src/vnode'
import { Data } from '../src/component'
import { ShapeFlags, PatchFlags } from '@vue/shared'
import { h, reactive, isReactive } from '../src'
import { h, reactive, isReactive, setBlockTracking } from '../src'
import { createApp, nodeOps, serializeInner } from '@vue/runtime-test'
import { setCurrentRenderingInstance } from '../src/componentRenderUtils'

Expand Down Expand Up @@ -535,6 +535,18 @@ describe('vnode', () => {
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
expect(vnode1.dynamicChildren).toStrictEqual([vnode2])
})

test('should not track openBlock() when tracking is disabled', () => {
let vnode1
const vnode = (openBlock(),
createBlock('div', null, [
setBlockTracking(-1),
(vnode1 = (openBlock(), createBlock('div'))),
setBlockTracking(1),
vnode1
]))
expect(vnode.dynamicChildren).toStrictEqual([])
})
})

describe('transformVNodeArgs', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/vnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export function createBlock(
closeBlock()
// a block is always going to be patched, so track it as a child of its
// parent block
if (currentBlock) {
if (shouldTrack > 0 && currentBlock) {
currentBlock.push(vnode)
}
return vnode
Expand Down

0 comments on commit ad93fa4

Please sign in to comment.