Skip to content

Commit

Permalink
refactor(factory): improve fallback multiple v-if
Browse files Browse the repository at this point in the history
  • Loading branch information
ksh-code committed Jan 7, 2021
1 parent f7ddd26 commit fdb0c9a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/weex-vue-framework/factory.js
Expand Up @@ -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
};
Expand Down
13 changes: 13 additions & 0 deletions test/unit/features/component/component-scoped-slot.spec.js
Expand Up @@ -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: `<test><template v-if="0 === 1">hi</template><template v-if="1 === 0">hi2</template></test>`,
components: {
Test: {
template: `<div><slot>fallback</slot></div>`
}
}
}).$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
Expand Down

0 comments on commit fdb0c9a

Please sign in to comment.