@@ -85,28 +85,54 @@ export default {
85
85
const hasDetailsSlot = this . hasNormalizedSlot ( detailsSlotName )
86
86
const formatted = this . getFormattedValue ( item , field )
87
87
const key = field . key
88
+ // We only uses the helper components for sticky columns to
89
+ // improve performance of BTable/BTableLite by reducing the
90
+ // total number of vue instances created during render
91
+ const cellTag = field . stickyColumn
92
+ ? field . isRowHeader
93
+ ? BTh
94
+ : BTd
95
+ : field . isRowHeader
96
+ ? 'th'
97
+ : 'td'
98
+ const cellVariant =
99
+ item . _cellVariants && item . _cellVariants [ key ]
100
+ ? item . _cellVariants [ key ]
101
+ : field . variant || null
88
102
const data = {
89
103
// For the Vue key, we concatenate the column index and
90
104
// field key (as field keys could be duplicated)
91
105
// TODO: Although we do prevent duplicate field keys...
92
106
// So we could change this to: `row-${rowIndex}-cell-${key}`
93
107
key : `row-${ rowIndex } -cell-${ colIndex } -${ key } ` ,
94
108
class : [ field . class ? field . class : '' , this . getTdValues ( item , key , field . tdClass , '' ) ] ,
95
- props : {
96
- stackedHeading : this . isStacked ? field . label : null ,
97
- stickyColumn : field . stickyColumn ,
98
- variant :
99
- item . _cellVariants && item . _cellVariants [ key ]
100
- ? item . _cellVariants [ key ]
101
- : field . variant || null
102
- } ,
109
+ props : { } ,
103
110
attrs : {
104
111
'aria-colindex' : String ( colIndex + 1 ) ,
105
112
...( field . isRowHeader
106
113
? this . getThValues ( item , key , field . thAttr , 'row' , { } )
107
114
: this . getTdValues ( item , key , field . tdAttr , { } ) )
108
115
}
109
116
}
117
+ if ( field . stickyColumn ) {
118
+ // We are using the helper BTd or BTh
119
+ data . props = {
120
+ stackedHeading : this . isStacked ? field . label : null ,
121
+ stickyColumn : field . stickyColumn ,
122
+ variant : cellVariant
123
+ }
124
+ } else {
125
+ // Using native TD or TH element, so we need to
126
+ // add in the attributes and variant class
127
+ data . attrs [ 'data-label' ] =
128
+ this . isStacked && ! isUndefinedOrNull ( field . label ) ? toString ( field . label ) : null
129
+ data . attrs . role = field . isRowHeader ? 'rowheader' : 'cell'
130
+ data . attrs . scope = field . isRowHeader ? 'row' : null
131
+ // Add in the variant class
132
+ if ( cellVariant ) {
133
+ data . class . push ( `${ this . dark ? 'bg' : 'table' } -${ cellVariant } ` )
134
+ }
135
+ }
110
136
const slotScope = {
111
137
item : item ,
112
138
index : rowIndex ,
@@ -135,7 +161,7 @@ export default {
135
161
$childNodes = [ h ( 'div' , { } , [ $childNodes ] ) ]
136
162
}
137
163
// Render either a td or th cell
138
- return h ( field . isRowHeader ? BTh : BTd , data , [ $childNodes ] )
164
+ return h ( cellTag , data , [ $childNodes ] )
139
165
} ,
140
166
renderTbodyRow ( item , rowIndex ) {
141
167
// Renders an item's row (or rows if details supported)
0 commit comments