Skip to content

Commit fdb0c9a

Browse files
author
ksh-code
committed
refactor(factory): improve fallback multiple v-if
close vuejs#9658
1 parent f7ddd26 commit fdb0c9a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/weex-vue-framework/factory.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -2590,8 +2590,7 @@ function normalizeScopedSlot(normalSlots, key, fn) {
25902590
? [res] // single vnode
25912591
: normalizeChildren(res);
25922592
return res && (
2593-
res.length === 0 ||
2594-
(res.length === 1 && res[0].isComment) // #9658
2593+
res.every(r => r.isComment) // #9658, #11856
25952594
) ? undefined
25962595
: res
25972596
};

test/unit/features/component/component-scoped-slot.spec.js

+13
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,19 @@ describe('Component scoped slot', () => {
12941294
expect(vm.$el.textContent).toMatch('fallback')
12951295
})
12961296

1297+
//#11856
1298+
it('fallback for scoped slot with multiple v-if', () => {
1299+
const vm = new Vue({
1300+
template: `<test><template v-if="0 === 1">hi</template><template v-if="1 === 0">hi2</template></test>`,
1301+
components: {
1302+
Test: {
1303+
template: `<div><slot>fallback</slot></div>`
1304+
}
1305+
}
1306+
}).$mount()
1307+
expect(vm.$el.textContent).toMatch('fallback')
1308+
})
1309+
12971310
// #9699
12981311
// Component only has normal slots, but is passing down $scopedSlots directly
12991312
// $scopedSlots should not be marked as stable in this case

0 commit comments

Comments
 (0)