Skip to content

Commit 62fb0b6

Browse files
authored
fix(b-link): only add the nativeOn property to componentData when rendering a router link (#3976)
1 parent f3ec2a1 commit 62fb0b6

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/components/link/link.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ export const BLink = /*#__PURE__*/ Vue.extend({
153153
const href = this.computedHref
154154
const isRouterLink = this.isRouterLink
155155

156-
// We want to overwrite any click handler since our callback
157-
// will invoke the user supplied handler9s) if !props.disabled
158-
const handlers = { ...this.$listeners, click: this.onClick }
159-
160156
const componentData = {
161157
class: { active: this.active, disabled: this.disabled },
162158
attrs: {
@@ -170,9 +166,16 @@ export const BLink = /*#__PURE__*/ Vue.extend({
170166
: this.$attrs.tabindex,
171167
'aria-disabled': this.disabled ? 'true' : null
172168
},
173-
props: this.computedProps,
174-
on: isRouterLink ? {} : handlers,
175-
nativeOn: isRouterLink ? handlers : {}
169+
props: this.computedProps
170+
}
171+
// Add the event handlers. We must use `navtiveOn` for
172+
// `<router-link>`/`<nuxt-link>` instead of `on`
173+
componentData[isRouterLink ? 'nativeOn' : 'on'] = {
174+
// Transfer all listeners (native) to the root element
175+
...this.$listeners,
176+
// We want to overwrite any click handler since our callback
177+
// will invoke the user supplied handler(s) if `!this.disabled`
178+
click: this.onClick
176179
}
177180

178181
// If href attribute exists on <router-link> (even undefined or null) it fails working on

0 commit comments

Comments
 (0)