]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test(runtime-core): add test case for `createBlock` with disableTracking (#1169)
authorunderfin <2218301630@qq.com>
Mon, 18 May 2020 14:20:05 +0000 (22:20 +0800)
committerGitHub <noreply@github.com>
Mon, 18 May 2020 14:20:05 +0000 (10:20 -0400)
packages/runtime-core/__tests__/vnode.spec.ts

index b25a6682ddadc157b232405ac30b590b8f8bb37c..5f27d99c4a493f8f1098ded3faa6dfd94e17b9af 100644 (file)
@@ -405,6 +405,39 @@ describe('vnode', () => {
       }))
       expect(vnode.dynamicChildren).toStrictEqual([vnode1])
     })
+
+    test('openBlock w/ disableTracking: true', () => {
+      const hoist = createVNode('div')
+      let vnode1
+      const vnode = (openBlock(),
+      createBlock('div', null, [
+        // a v-for fragment block generated by the compiler
+        // disables tracking because it always diffs its
+        // children.
+        (vnode1 = (openBlock(true),
+        createBlock(Fragment, null, [
+          hoist,
+          /*vnode2*/ createVNode(() => {}, null, 'text')
+        ])))
+      ]))
+      expect(vnode.dynamicChildren).toStrictEqual([vnode1])
+      expect(vnode1.dynamicChildren).toStrictEqual([])
+    })
+
+    test('openBlock without disableTracking: true', () => {
+      const hoist = createVNode('div')
+      let vnode1, vnode2
+      const vnode = (openBlock(),
+      createBlock('div', null, [
+        (vnode1 = (openBlock(),
+        createBlock(Fragment, null, [
+          hoist,
+          (vnode2 = createVNode(() => {}, null, 'text'))
+        ])))
+      ]))
+      expect(vnode.dynamicChildren).toStrictEqual([vnode1])
+      expect(vnode1.dynamicChildren).toStrictEqual([vnode2])
+    })
   })
 
   describe('transformVNodeArgs', () => {