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

Commit a9a3a8b

Browse files
authored
Update mixin-tbody-row.js
1 parent fb4e125 commit a9a3a8b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { BTd } from '../td'
66
import { BTh } from '../th'
77

88
const detailsSlotName = 'row-details'
9+
const noop = () => {}
910

1011
export default {
1112
props: {
@@ -180,6 +181,8 @@ export default {
180181
const hasDetailsSlot = this.hasNormalizedSlot(detailsSlotName)
181182
const rowShowDetails = Boolean(item._showDetails && hasDetailsSlot)
182183
const hasRowClickHandler = this.$listeners['row-clicked'] || this.hasSelectableRowClick
184+
const hasRowHoveredHandler = this.$listeners['row-hovered']
185+
const hasRowUnhoveredHandler = this.$listeners['row-unhovered']
183186

184187
// We can return more than one TR if rowDetails enabled
185188
const $rows = []
@@ -241,8 +244,9 @@ export default {
241244
},
242245
on: {
243246
// Note: These events are not A11Y friendly!
244-
mouseenter: this.rowHovered,
245-
mouseleave: this.rowUnhovered
247+
// Event handlers only called if there are listeners registered
248+
mouseenter: hasRowHoveredHandler ? this.rowHovered : noop,
249+
mouseleave: hasRowUnhoveredHandler ? this.rowUnhovered : noop
246250
}
247251
},
248252
$tds

0 commit comments

Comments
 (0)