From 4f9f772c58be9eac5c5228ca5832f53fd3ebc581 Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Tue, 20 Aug 2019 14:25:57 -0300 Subject: [PATCH 1/2] fix(b-table, b-table-lite): handle edge case where field slot returns no vNodes (fixes #3919) Fixes an edge case where user conditionally renders content inside a scoped slot, which was causing the cell to be rendered with the raw value when it shouldn't. Fixes #3919 --- src/components/table/helpers/mixin-tbody-row.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/table/helpers/mixin-tbody-row.js b/src/components/table/helpers/mixin-tbody-row.js index 784d8132277..9507c1bcb57 100644 --- a/src/components/table/helpers/mixin-tbody-row.js +++ b/src/components/table/helpers/mixin-tbody-row.js @@ -204,7 +204,9 @@ export default { // a square bracket and if using in-document HTML templates, the // v-slot attributes are lower-cased by the browser. const slotNames = [`cell[${key}]`, `cell[${key.toLowerCase()}]`, 'cell[]'] - let $childNodes = this.normalizeSlot(slotNames, slotScope) || toString(formatted) + let $childNodes = this.hasNormalizedSlot(slotNames) + ? this.normalizeSlot(slotNames, slotScope) + : toString(formatted) if (this.isStacked) { // We wrap in a DIV to ensure rendered as a single cell when visually stacked! $childNodes = [h('div', {}, [$childNodes])] From f5a5aad563e5c0ca8d4d477a2efcd4708dabc017 Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Tue, 20 Aug 2019 14:34:44 -0300 Subject: [PATCH 2/2] Update mixin-thead.js --- src/components/table/helpers/mixin-thead.js | 26 +++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/components/table/helpers/mixin-thead.js b/src/components/table/helpers/mixin-thead.js index 564f2e9ab32..361c559dc62 100644 --- a/src/components/table/helpers/mixin-thead.js +++ b/src/components/table/helpers/mixin-thead.js @@ -116,20 +116,22 @@ export default { ...slotNames ] } - const slot = this.normalizeSlot(slotNames, { - label: field.label, - column: field.key, - field, - isFoot, - // Add in row select methods - selectAllRows, - clearSelected - }) - if (!slot) { - // need to check if this will work + const hasSlot = this.hasNormalizedSlot(slotNames) + let slot = field.label + if (hasSlot) { + slot = this.normalizeSlot(slotNames, { + label: field.label, + column: field.key, + field, + isFoot, + // Add in row select methods + selectAllRows, + clearSelected + }) + } else { data.domProps = htmlOrText(field.labelHtml) } - return h(BTh, data, slot || field.label) + return h(BTh, data, slot) } // Generate the array of cells