@@ -75,22 +75,32 @@ export class FTable extends FRoot {
75
75
await this . updateHeaderSelectionCheckboxState ( ) ;
76
76
}
77
77
if ( this . selectable === "single" ) {
78
- const headerRow = this . querySelector < FTrow > ( ":scope > f-trow[selected][slot='header']" ) ;
78
+ const headerRow = Array . from ( this . children ) . filter (
79
+ el =>
80
+ el . tagName . toLocaleLowerCase ( ) === "f-trow" &&
81
+ el . getAttribute ( "slot" ) === "header" &&
82
+ el . hasAttribute ( "selected" )
83
+ ) [ 0 ] as FTrow ;
79
84
if ( headerRow ) {
80
85
headerRow . selected = false ;
81
86
}
82
87
83
- const selectedRow = this . querySelector < FTrow > (
84
- ":scope > f-trow[selected]:not([slot='header'])"
85
- ) ;
88
+ const selectedRow = Array . from ( this . children ) . filter (
89
+ el =>
90
+ el . tagName . toLocaleLowerCase ( ) === "f-trow" &&
91
+ el . getAttribute ( "slot" ) !== "header" &&
92
+ el . hasAttribute ( "selected" )
93
+ ) [ 0 ] as FTrow ;
86
94
if ( selectedRow ) {
87
95
this . updateRadioChecks ( selectedRow ) ;
88
96
}
89
97
}
90
98
}
91
99
92
100
updateGridTemplateColumns ( ) {
93
- const firstRow = this . querySelector ( ":scope > f-trow" ) ;
101
+ const firstRow = Array . from ( this . children ) . filter (
102
+ el => el . tagName . toLocaleLowerCase ( ) === "f-trow"
103
+ ) [ 0 ] as FTrow ;
94
104
if ( firstRow !== null ) {
95
105
/**
96
106
* following query is not working vue app so replaced with firstRow.children
@@ -116,7 +126,9 @@ export class FTable extends FRoot {
116
126
* apply checkbox or radio based on selection property
117
127
*/
118
128
applySelectable ( ) {
119
- const allRows = this . querySelectorAll < FTrow > ( ":scope > f-trow" ) ;
129
+ const allRows = Array . from ( this . children ) . filter (
130
+ el => el . tagName . toLocaleLowerCase ( ) === "f-trow"
131
+ ) as FTrow [ ] ;
120
132
allRows . forEach ( row => {
121
133
const firstChild = Array . from ( row . children ) . find ( child => {
122
134
return child . tagName === "F-TCELL" ;
@@ -134,7 +146,9 @@ export class FTable extends FRoot {
134
146
async handleHeaderRowSelection ( event : CustomEvent ) {
135
147
event . stopPropagation ( ) ;
136
148
if ( this . selectable === "multiple" ) {
137
- const allRows = this . querySelectorAll < FTrow > ( ":scope > f-trow" ) ;
149
+ const allRows = Array . from ( this . children ) . filter (
150
+ el => el . tagName . toLocaleLowerCase ( ) === "f-trow"
151
+ ) as FTrow [ ] ;
138
152
if ( event . detail . value === true ) {
139
153
allRows . forEach ( r => {
140
154
if ( ! r . disableSelection ) {
@@ -167,9 +181,12 @@ export class FTable extends FRoot {
167
181
}
168
182
169
183
dispatchSelectedRowEvent ( ) {
170
- const selectedRows = this . querySelectorAll < FTrow > (
171
- ":scope > f-trow[selected]:not([slot='header'])"
172
- ) ;
184
+ const selectedRows = Array . from ( this . children ) . filter (
185
+ el =>
186
+ el . tagName . toLocaleLowerCase ( ) === "f-trow" &&
187
+ el . getAttribute ( "slot" ) !== "header" &&
188
+ el . hasAttribute ( "selected" )
189
+ ) as FTrow [ ] ;
173
190
const toggle = new CustomEvent ( "selected-rows" , {
174
191
detail : Array . from ( selectedRows ) ,
175
192
bubbles : true ,
@@ -183,7 +200,9 @@ export class FTable extends FRoot {
183
200
*/
184
201
updateRadioChecks ( element : HTMLElement ) {
185
202
if ( this . selectable === "single" ) {
186
- const allRows = this . querySelectorAll < FTrow > ( ":scope > f-trow:not([slot='header'])" ) ;
203
+ const allRows = Array . from ( this . children ) . filter (
204
+ el => el . tagName . toLocaleLowerCase ( ) === "f-trow" && el . getAttribute ( "slot" ) !== "header"
205
+ ) as FTrow [ ] ;
187
206
188
207
allRows . forEach ( row => {
189
208
if ( row . selected && row !== element ) {
@@ -197,15 +216,21 @@ export class FTable extends FRoot {
197
216
*/
198
217
async updateHeaderSelectionCheckboxState ( ) {
199
218
if ( this . selectable === "multiple" ) {
200
- const allRows = this . querySelectorAll < FTrow > ( ":scope > f-trow" ) ;
219
+ const allRows = Array . from ( this . children ) . filter (
220
+ el => el . tagName . toLocaleLowerCase ( ) === "f-trow"
221
+ ) as FTrow [ ] ;
201
222
const rowsWithoutHeader = Array . from ( allRows ) . filter (
202
223
r => r . getAttribute ( "slot" ) !== "header"
203
224
) ;
204
225
const selectedRows = rowsWithoutHeader . filter ( r => r . selected ) ;
205
- const headerRow = this . querySelector < FTrow > ( ":scope > f-trow[slot='header']" ) ;
226
+ const headerRow = Array . from ( this . children ) . filter (
227
+ el => el . tagName . toLocaleLowerCase ( ) === "f-trow" && el . getAttribute ( "slot" ) === "header"
228
+ ) [ 0 ] as FTrow ;
206
229
if ( headerRow ) {
207
230
await headerRow . updateComplete ;
208
- const firstCell = headerRow . querySelector < FTcell > ( ":scope > f-tcell" ) ;
231
+ const firstCell = Array . from ( headerRow . children ) . filter (
232
+ el => el . tagName . toLocaleLowerCase ( ) === "f-tcell"
233
+ ) [ 0 ] as FTcell ;
209
234
if ( firstCell ?. checkbox ) {
210
235
if ( selectedRows . length === 0 ) {
211
236
headerRow . selected = false ;
@@ -222,9 +247,13 @@ export class FTable extends FRoot {
222
247
223
248
toggleColumnHighlight ( event : CustomEvent ) {
224
249
if ( event . detail . columnIndex >= 0 ) {
225
- const allRows = this . querySelectorAll < FTrow > ( ":scope > f-trow" ) ;
250
+ const allRows = Array . from ( this . children ) . filter (
251
+ el => el . tagName . toLocaleLowerCase ( ) === "f-trow"
252
+ ) as FTrow [ ] ;
226
253
allRows . forEach ( row => {
227
- const allCells = row . querySelectorAll < FTrow > ( ":scope > f-tcell" ) ;
254
+ const allCells = Array . from ( row . children ) . filter (
255
+ el => el . tagName . toLocaleLowerCase ( ) === "f-tcell"
256
+ ) as FTcell [ ] ;
228
257
if ( event . detail . type === "add" ) {
229
258
allCells [ event . detail . columnIndex ] ?. classList . add ( "highlight" ) ;
230
259
} else {
@@ -236,9 +265,13 @@ export class FTable extends FRoot {
236
265
237
266
toggleColumnSelected ( event : CustomEvent ) {
238
267
if ( event . detail . columnIndex >= 0 ) {
239
- const allRows = this . querySelectorAll < FTrow > ( ":scope > f-trow" ) ;
268
+ const allRows = Array . from ( this . children ) . filter (
269
+ el => el . tagName . toLocaleLowerCase ( ) === "f-trow"
270
+ ) as FTrow [ ] ;
240
271
allRows . forEach ( row => {
241
- const allCells = row . querySelectorAll < FTrow > ( ":scope > f-tcell" ) ;
272
+ const allCells = Array . from ( row . children ) . filter (
273
+ el => el . tagName . toLocaleLowerCase ( ) === "f-tcell"
274
+ ) as FTcell [ ] ;
242
275
if ( allCells [ event . detail . columnIndex ] ) {
243
276
allCells [ event . detail . columnIndex ] . selected =
244
277
! allCells [ event . detail . columnIndex ] . selected ;
0 commit comments