🌐 AI搜索 & 代理 主页
Skip to content

Commit f3334c2

Browse files
authored
fix(b-table, b-table-lite): handle edge case with row events when table is removed from dom (fixes #4384)
1 parent ed3b736 commit f3334c2

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ export default {
2424
// `this.$refs.itemRows` is an array of item TR components/elements
2525
// Rows should all be B-TR components, but we map to TR elements
2626
// Also note that `this.$refs.itemRows` may not always be in document order
27-
const tbody = this.$refs.tbody.$el || this.$refs.tbody
28-
const trs = (this.$refs.itemRows || []).map(tr => tr.$el || tr)
29-
// TODO: This may take time for tables many rows, so we may want to cache
30-
// the result of this during each render cycle on a non-reactive
31-
// property. We clear out the cache as each render starts, and
32-
// populate it on first access of this method if null
33-
return arrayFrom(tbody.children).filter(tr => arrayIncludes(trs, tr))
27+
const refs = this.$refs || {}
28+
const tbody = refs.tbody ? refs.tbody.$el || refs.tbody : null
29+
const trs = (refs.itemRows || []).map(tr => tr.$el || tr)
30+
return tbody && trs.length
31+
? arrayFrom(tbody.children).filter(tr => arrayIncludes(trs, tr))
32+
: []
3433
},
3534
getTbodyTrIndex(el) {
3635
// Returns index of a particular TBODY item TR

0 commit comments

Comments
 (0)