From fdb0c9a3a0951cb12e90a8983cbe1b1472cf212e Mon Sep 17 00:00:00 2001 From: ksh-code Date: Thu, 7 Jan 2021 20:04:56 +0900 Subject: [PATCH] refactor(factory): improve fallback multiple v-if close #9658 --- packages/weex-vue-framework/factory.js | 3 +-- .../component/component-scoped-slot.spec.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/weex-vue-framework/factory.js b/packages/weex-vue-framework/factory.js index 4cb547b5250..fa2ac553a38 100644 --- a/packages/weex-vue-framework/factory.js +++ b/packages/weex-vue-framework/factory.js @@ -2590,8 +2590,7 @@ function normalizeScopedSlot(normalSlots, key, fn) { ? [res] // single vnode : normalizeChildren(res); return res && ( - res.length === 0 || - (res.length === 1 && res[0].isComment) // #9658 + res.every(r => r.isComment) // #9658, #11856 ) ? undefined : res }; diff --git a/test/unit/features/component/component-scoped-slot.spec.js b/test/unit/features/component/component-scoped-slot.spec.js index 28369814f48..1eb53f6034f 100644 --- a/test/unit/features/component/component-scoped-slot.spec.js +++ b/test/unit/features/component/component-scoped-slot.spec.js @@ -1294,6 +1294,19 @@ describe('Component scoped slot', () => { expect(vm.$el.textContent).toMatch('fallback') }) + //#11856 + it('fallback for scoped slot with multiple v-if', () => { + const vm = new Vue({ + template: ``, + components: { + Test: { + template: `
fallback
` + } + } + }).$mount() + expect(vm.$el.textContent).toMatch('fallback') + }) + // #9699 // Component only has normal slots, but is passing down $scopedSlots directly // $scopedSlots should not be marked as stable in this case