Skip to content

Commit b637f1b

Browse files
committed
Simplify code.
Using optional argument to check if exist slot "thread-top". Avoid some manual castings not really required, the IDE can detected by himself.
1 parent 737d53a commit b637f1b

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/components/BTable/BTable.vue

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,11 @@ export default defineComponent({
4444
const computedFields = computed(() => itemHelper.normaliseFields(props.fields, props.items))
4545
4646
return () => {
47-
let theadTop: VNode | null = null
48-
if (slots['thead-top']) {
49-
theadTop = slots['thead-top']() as unknown as VNode
50-
}
47+
const theadTop = slots['thead-top']?.()
5148
52-
let theadSub: VNode | null
53-
theadSub = null
54-
if (slots['thead-sub']) {
55-
const slotReference = slots['thead-sub'] as unknown as (arg: object) => VNode
49+
let theadSub: VNode | undefined
50+
const slotReference = slots['thead-sub']
51+
if (slotReference) {
5652
theadSub = h(
5753
'tr',
5854
@@ -63,7 +59,7 @@ export default defineComponent({
6359
scope: 'col',
6460
class: [field.class, field.thClass, field.variant ? `table-${field.variant}` : ''],
6561
},
66-
slotReference({items: computedFields.value, ...field}) as unknown as VNode
62+
slotReference({items: computedFields.value, ...field})
6763
)
6864
)
6965
)

0 commit comments

Comments
 (0)