]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler): fix v-for fragment openBlock argument
authorEvan You <yyx990803@gmail.com>
Mon, 10 Feb 2020 23:19:49 +0000 (18:19 -0500)
committerEvan You <yyx990803@gmail.com>
Mon, 10 Feb 2020 23:19:49 +0000 (18:19 -0500)
packages/compiler-core/__tests__/__snapshots__/compile.spec.ts.snap
packages/compiler-core/__tests__/transforms/__snapshots__/hoistStatic.spec.ts.snap
packages/compiler-core/__tests__/transforms/__snapshots__/transformText.spec.ts.snap
packages/compiler-core/__tests__/transforms/__snapshots__/vFor.spec.ts.snap
packages/compiler-core/src/transforms/vFor.ts
packages/compiler-ssr/__tests__/ssrComponent.spec.ts
packages/runtime-core/src/vnode.ts

index 21168dc096a2109452e9919c6033708d074f5ce0..7afb6ffde877b9cb99e82c01c663ae7bf64e43a3 100644 (file)
@@ -15,7 +15,7 @@ return function render(_ctx, _cache) {
       (_openBlock(), ok
         ? _createBlock(\\"div\\", { key: 0 }, \\"yes\\")
         : _createBlock(_Fragment, { key: 1 }, [\\"no\\"])),
-      (_openBlock(false), _createBlock(_Fragment, null, _renderList(list, (value, index) => {
+      (_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (value, index) => {
         return (_openBlock(), _createBlock(\\"div\\", null, [
           _createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
         ]))
@@ -37,7 +37,7 @@ return function render(_ctx, _cache) {
     (_openBlock(), (_ctx.ok)
       ? _createBlock(\\"div\\", { key: 0 }, \\"yes\\")
       : _createBlock(_Fragment, { key: 1 }, [\\"no\\"])),
-    (_openBlock(false), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
+    (_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
       return (_openBlock(), _createBlock(\\"div\\", null, [
         _createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
       ]))
@@ -58,7 +58,7 @@ export function render(_ctx, _cache) {
     (_openBlock(), (_ctx.ok)
       ? _createBlock(\\"div\\", { key: 0 }, \\"yes\\")
       : _createBlock(_Fragment, { key: 1 }, [\\"no\\"])),
-    (_openBlock(false), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
+    (_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
       return (_openBlock(), _createBlock(\\"div\\", null, [
         _createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
       ]))
index 0b355441d6d285864fd01260189583dd0a74b5d4..205a134786da219368dd567c91d0483ef7f0382b 100644 (file)
@@ -229,7 +229,7 @@ return function render(_ctx, _cache) {
     const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, toDisplayString: _toDisplayString, createVNode: _createVNode } = _Vue
 
     return (_openBlock(), _createBlock(\\"div\\", null, [
-      (_openBlock(false), _createBlock(_Fragment, null, _renderList(_ctx.list, (o) => {
+      (_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (o) => {
         return (_openBlock(), _createBlock(\\"p\\", null, [
           _createVNode(\\"span\\", null, _toDisplayString(o + 'foo'), 1 /* TEXT */)
         ]))
@@ -264,7 +264,7 @@ return function render(_ctx, _cache) {
     const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, toDisplayString: _toDisplayString, createVNode: _createVNode } = _Vue
 
     return (_openBlock(), _createBlock(\\"div\\", null, [
-      (_openBlock(false), _createBlock(_Fragment, null, _renderList(_ctx.list, (o) => {
+      (_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (o) => {
         return (_openBlock(), _createBlock(\\"p\\", null, [
           _createVNode(\\"span\\", null, _toDisplayString(o), 1 /* TEXT */)
         ]))
@@ -356,7 +356,7 @@ return function render(_ctx, _cache) {
     const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
 
     return (_openBlock(), _createBlock(\\"div\\", null, [
-      (_openBlock(false), _createBlock(_Fragment, null, _renderList(list, (i) => {
+      (_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (i) => {
         return (_openBlock(), _createBlock(\\"div\\", _hoisted_1, [
           _hoisted_2
         ]))
index 8c133b2193888871bb2df8efde64583e7eda294d..f75897739334a0fea35f44d1f3d64e0f73db7d70 100644 (file)
@@ -7,7 +7,7 @@ return function render(_ctx, _cache) {
   with (this) {
     const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createTextVNode: _createTextVNode } = _Vue
 
-    return (_openBlock(false), _createBlock(_Fragment, null, _renderList(list, (i) => {
+    return (_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (i) => {
       return (_openBlock(), _createBlock(_Fragment, null, [
         _createTextVNode(\\"foo\\")
       ], 64 /* STABLE_FRAGMENT */))
index 884344fe50b62b89760f07aec2515b84624bbded..f896882061b4369583d6a305fff8fe6678b7801f 100644 (file)
@@ -7,7 +7,7 @@ return function render(_ctx, _cache) {
   with (this) {
     const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
 
-    return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (item) => {
+    return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
       return (_openBlock(), _createBlock(\\"span\\"))
     }), 256 /* UNKEYED_FRAGMENT */))
   }
@@ -21,7 +21,7 @@ return function render(_ctx, _cache) {
   with (this) {
     const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
 
-    return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (item) => {
+    return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
       return (_openBlock(), _createBlock(_Fragment, { key: item }, [
         \\"hello\\",
         _createVNode(\\"span\\")
@@ -38,7 +38,7 @@ return function render(_ctx, _cache) {
   with (this) {
     const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
 
-    return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (item) => {
+    return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
       return (_openBlock(), _createBlock(\\"span\\", { key: item }))
     }), 128 /* KEYED_FRAGMENT */))
   }
@@ -52,7 +52,7 @@ return function render(_ctx, _cache) {
   with (this) {
     const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
 
-    return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (item, __, index) => {
+    return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item, __, index) => {
       return (_openBlock(), _createBlock(\\"span\\"))
     }), 256 /* UNKEYED_FRAGMENT */))
   }
@@ -66,7 +66,7 @@ return function render(_ctx, _cache) {
   with (this) {
     const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
 
-    return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (_, __, index) => {
+    return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (_, __, index) => {
       return (_openBlock(), _createBlock(\\"span\\"))
     }), 256 /* UNKEYED_FRAGMENT */))
   }
@@ -80,7 +80,7 @@ return function render(_ctx, _cache) {
   with (this) {
     const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
 
-    return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (_, key, index) => {
+    return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (_, key, index) => {
       return (_openBlock(), _createBlock(\\"span\\"))
     }), 256 /* UNKEYED_FRAGMENT */))
   }
@@ -94,7 +94,7 @@ return function render(_ctx, _cache) {
   with (this) {
     const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
 
-    return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (item) => {
+    return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
       return (_openBlock(), _createBlock(_Fragment, null, [
         \\"hello\\",
         _createVNode(\\"span\\")
@@ -111,7 +111,7 @@ return function render(_ctx, _cache) {
   with (this) {
     const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, renderSlot: _renderSlot } = _Vue
 
-    return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (item) => {
+    return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
       return _renderSlot($slots, \\"default\\")
     }), 256 /* UNKEYED_FRAGMENT */))
   }
@@ -125,7 +125,7 @@ return function render(_ctx, _cache) {
   with (this) {
     const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, renderSlot: _renderSlot } = _Vue
 
-    return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (item) => {
+    return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
       return _renderSlot($slots, \\"default\\")
     }), 256 /* UNKEYED_FRAGMENT */))
   }
@@ -141,7 +141,7 @@ return function render(_ctx, _cache) {
 
     const _directive_foo = _resolveDirective(\\"foo\\")
 
-    return (_openBlock(false), _createBlock(_Fragment, null, _renderList(list, (i) => {
+    return (_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (i) => {
       return (_openBlock(), _withDirectives(_createBlock(\\"div\\", null, null, 32 /* NEED_PATCH */), [
         [_directive_foo]
       ]))
@@ -173,7 +173,7 @@ return function render(_ctx, _cache) {
   with (this) {
     const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue
 
-    return (_openBlock(false), _createBlock(_Fragment, null, _renderList(items, (item, key, index) => {
+    return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item, key, index) => {
       return (_openBlock(), _createBlock(\\"span\\"))
     }), 256 /* UNKEYED_FRAGMENT */))
   }
index 1032c0a564372c81fe9030e78a721932162c6715..48b2e3d1e8231b7b84de2e4238544b7f5d99d4a5 100644 (file)
@@ -57,8 +57,9 @@ export const transformFor = createStructuralDirectiveTransform(
         ? PatchFlags.KEYED_FRAGMENT
         : PatchFlags.UNKEYED_FRAGMENT
       forNode.codegenNode = createSequenceExpression([
-        // fragment blocks disable tracking since they always diff their children
-        createCallExpression(helper(OPEN_BLOCK), [`false`]),
+        // v-for fragment blocks disable tracking since they always diff their
+        // children
+        createCallExpression(helper(OPEN_BLOCK), [`true`]),
         createCallExpression(helper(CREATE_BLOCK), [
           helper(FRAGMENT),
           `null`,
index 2318134cfa845be1f75cefa3753fec2d982dcb1a..828741b69069b4367d37db6717cdc1b92a39cf91 100644 (file)
@@ -231,7 +231,7 @@ describe('ssr: components', () => {
                 return [
                   (_openBlock(), (_ctx.ok)
                     ? _createBlock(\\"div\\", { key: 0 }, [
-                        (_openBlock(false), _createBlock(_Fragment, null, _renderList(list, (i) => {
+                        (_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (i) => {
                           return (_openBlock(), _createBlock(\\"span\\"))
                         }), 256 /* UNKEYED_FRAGMENT */))
                       ])
@@ -254,7 +254,7 @@ describe('ssr: components', () => {
                 return [
                   (_openBlock(), ok
                     ? _createBlock(\\"div\\", { key: 0 }, [
-                        (_openBlock(false), _createBlock(_Fragment, null, _renderList(_ctx.list, (i) => {
+                        (_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (i) => {
                           return (_openBlock(), _createBlock(\\"span\\"))
                         }), 256 /* UNKEYED_FRAGMENT */))
                       ])
index 97b09eb0d8f78dc7c686e4ca3a501c4f57dbb351..c57dfae02f43615bbf4862ab5ce3ba19e15e05df 100644 (file)
@@ -134,7 +134,7 @@ let currentBlock: VNode[] | null = null
 //
 // disableTracking is true when creating a fragment block, since a fragment
 // always diffs its children.
-export function openBlock(disableTracking?: boolean) {
+export function openBlock(disableTracking = false) {
   blockStack.push((currentBlock = disableTracking ? null : []))
 }