Skip to content

Commit a392059

Browse files
authored
fix(b-table, b-table-lite): handle edge case where field slot returns no vNodes (fixes #3919) (#3920)
1 parent 611a507 commit a392059

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/components/table/helpers/mixin-tbody-row.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ export default {
204204
// a square bracket and if using in-document HTML templates, the
205205
// v-slot attributes are lower-cased by the browser.
206206
const slotNames = [`cell[${key}]`, `cell[${key.toLowerCase()}]`, 'cell[]']
207-
let $childNodes = this.normalizeSlot(slotNames, slotScope) || toString(formatted)
207+
let $childNodes = this.hasNormalizedSlot(slotNames)
208+
? this.normalizeSlot(slotNames, slotScope)
209+
: toString(formatted)
208210
if (this.isStacked) {
209211
// We wrap in a DIV to ensure rendered as a single cell when visually stacked!
210212
$childNodes = [h('div', {}, [$childNodes])]

src/components/table/helpers/mixin-thead.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,22 @@ export default {
116116
...slotNames
117117
]
118118
}
119-
const slot = this.normalizeSlot(slotNames, {
120-
label: field.label,
121-
column: field.key,
122-
field,
123-
isFoot,
124-
// Add in row select methods
125-
selectAllRows,
126-
clearSelected
127-
})
128-
if (!slot) {
129-
// need to check if this will work
119+
const hasSlot = this.hasNormalizedSlot(slotNames)
120+
let slot = field.label
121+
if (hasSlot) {
122+
slot = this.normalizeSlot(slotNames, {
123+
label: field.label,
124+
column: field.key,
125+
field,
126+
isFoot,
127+
// Add in row select methods
128+
selectAllRows,
129+
clearSelected
130+
})
131+
} else {
130132
data.domProps = htmlOrText(field.labelHtml)
131133
}
132-
return h(BTh, data, slot || field.label)
134+
return h(BTh, data, slot)
133135
}
134136

135137
// Generate the array of <th> cells

0 commit comments

Comments
 (0)