From 2bc36bd820ea9175bd1af80d0ea4c81496d3d3b1 Mon Sep 17 00:00:00 2001 From: ygj6 Date: Sat, 21 Nov 2020 15:45:04 +0800 Subject: [PATCH 1/2] fix(test): npm test fails on Windows close vuejs#11782 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2921aafda83..7d40666d05c 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "flow-bin": "^0.61.0", "hash-sum": "^1.0.2", "he": "^1.1.1", - "http-server": "^0.11.1", + "http-server": "^0.12.3", "jasmine": "^2.99.0", "jasmine-core": "^2.99.0", "karma": "^3.1.1", From 1297c7053271fbcf979fb430a5a09da0a0aa9c11 Mon Sep 17 00:00:00 2001 From: ygj6 Date: Fri, 27 Nov 2020 15:40:44 +0800 Subject: [PATCH 2/2] fix(slot): force update when swtching between two components with slot and without slot close #11652 --- src/core/instance/lifecycle.js | 3 ++- .../component/component-scoped-slot.spec.js | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/core/instance/lifecycle.js b/src/core/instance/lifecycle.js index b7265df0aaf..c35129a45f8 100644 --- a/src/core/instance/lifecycle.js +++ b/src/core/instance/lifecycle.js @@ -234,7 +234,8 @@ export function updateChildComponent ( const hasDynamicScopedSlot = !!( (newScopedSlots && !newScopedSlots.$stable) || (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) || - (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) + (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) || + (!newScopedSlots && vm.$scopedSlots.$key) ) // Any static slot children from the parent may have changed during parent's diff --git a/test/unit/features/component/component-scoped-slot.spec.js b/test/unit/features/component/component-scoped-slot.spec.js index 28369814f48..8e9d584ae3e 100644 --- a/test/unit/features/component/component-scoped-slot.spec.js +++ b/test/unit/features/component/component-scoped-slot.spec.js @@ -1325,4 +1325,28 @@ describe('Component scoped slot', () => { expect(vm.$el.textContent).toMatch(`1`) }).then(done) }) + + // #11652 + it('should update when swtching between two components with slot and without slot', done => { + const Child = { + template: `
` + } + + const parent = new Vue({ + template: `
+ + +
`, + data: { + flag: true + }, + components: { Child } + }).$mount() + + expect(parent.$el.textContent).toMatch(`foo`) + parent.flag=false + waitForUpdate(()=>{ + expect(parent.$el.textContent).toMatch(``) + }).then(done) + }) })