]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-core): openBlock() should not be tracked when block tracking is disabled
authorEvan You <yyx990803@gmail.com>
Wed, 2 Sep 2020 16:15:36 +0000 (12:15 -0400)
committerEvan You <yyx990803@gmail.com>
Wed, 2 Sep 2020 16:30:37 +0000 (12:30 -0400)
packages/runtime-core/__tests__/vnode.spec.ts
packages/runtime-core/src/vnode.ts

index 2ee1872afaac4eaca8dcc1eb4a4a81b23a8d6a06..0a08d4f3f5fe7242e4d76b6370f90e3ad95e351c 100644 (file)
@@ -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'
 
@@ -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', () => {
index de329ff945518d7d2efcc9c59905289f78aed1f9..0c468fd06d5b08491403e0a04b6c8c0a22f45729 100644 (file)
@@ -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