diff --git a/src/core/vdom/patch.js b/src/core/vdom/patch.js index 2052df913b3..c8f897bee2f 100644 --- a/src/core/vdom/patch.js +++ b/src/core/vdom/patch.js @@ -23,6 +23,7 @@ import { isDef, isUndef, isTrue, + isFalse, makeMap, isRegExp, isPrimitive @@ -643,7 +644,13 @@ export function createPatchFunction (backend) { let childrenMatch = true let childNode = elm.firstChild for (let i = 0; i < children.length; i++) { - if (!childNode || !hydrate(childNode, children[i], insertedVnodeQueue, inVPre)) { + const child = children[i] + // ignore empty text vnode but create a empty textNode for next patch + if (isUndef(child.tag) && isFalse(child.isComment) && child.text === '') { + createElm(child, insertedVnodeQueue, elm, childNode) + continue + } + if (!childNode || !hydrate(childNode, child, insertedVnodeQueue, inVPre)) { childrenMatch = false break } diff --git a/test/unit/modules/vdom/patch/hydration.spec.js b/test/unit/modules/vdom/patch/hydration.spec.js index 930ad47cc81..1037b8a4f88 100644 --- a/test/unit/modules/vdom/patch/hydration.spec.js +++ b/test/unit/modules/vdom/patch/hydration.spec.js @@ -388,4 +388,24 @@ describe('vdom patch: hydration', () => { expect(dom.children[0].className).toBe('bar') }).then(done) }) + + // #11109 + it('should not fail hydration with empty text vnodes children', done => { + const dom = createMockSSRDOM('
') + + const vm = new Vue({ + data: { + a: '' + }, + template: `