Skip to content

Commit b5e9b82

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

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Diff for: src/core/vdom/helpers/normalize-scoped-slots.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ function normalizeScopedSlot(normalSlots, key, fn) {
6161
? [res] // single vnode
6262
: normalizeChildren(res)
6363
return res && (
64-
res.length === 0 ||
65-
(res.length === 1 && res[0].isComment) // #9658
64+
res.every(r => r.isComment) // #9658, #11856
6665
) ? undefined
6766
: res
6867
}

Diff for: 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).toEqual('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)