diff --git a/src/core/vdom/patch.js b/src/core/vdom/patch.js index 2052df913b3..44afc8c4b15 100644 --- a/src/core/vdom/patch.js +++ b/src/core/vdom/patch.js @@ -547,6 +547,9 @@ export function createPatchFunction (backend) { const oldCh = oldVnode.children const ch = vnode.children + if (isDef(vnode.fnScopeId)) { + setScope(vnode) + } if (isDef(data) && isPatchable(vnode)) { for (i = 0; i < cbs.update.length; ++i) cbs.update[i](oldVnode, vnode) if (isDef(i = data.hook) && isDef(i = i.update)) i(oldVnode, vnode) diff --git a/test/unit/modules/vdom/patch/edge-cases.spec.js b/test/unit/modules/vdom/patch/edge-cases.spec.js index a7f7ba38932..95296b7120c 100644 --- a/test/unit/modules/vdom/patch/edge-cases.spec.js +++ b/test/unit/modules/vdom/patch/edge-cases.spec.js @@ -1,4 +1,5 @@ import Vue from 'vue' +import { patch } from 'web/runtime/patch' describe('vdom patch: edge cases', () => { // exposed by #3406 @@ -432,4 +433,25 @@ describe('vdom patch: edge cases', () => { expect(vm.$el.textContent).not.toMatch('Infinity') }).then(done) }) + + // #11171 + it("should replace functional element scope attribute", () => { + const vm = new Vue({ + components: { + foo: { + functional: true, + _scopeId: "foo", + render (h) { + return h('div') + } + } + } + }) + const h = vm.$createElement + const vnode = h('foo') + const oldVnode = h("div") + patch(null, oldVnode) + let elm = patch(oldVnode, vnode) + expect(elm.hasAttribute("foo")).toBe(true) + }) })