8000 fix(b-link): don't render `target` or `rel` attrs when `router-tag` o… · bootstrap-vue/bootstrap-vue@33c6cef · GitHub
[go: up one dir, main page]

Skip to content

Commit 33c6cef

Browse files
authored
fix(b-link): don't render target or rel attrs when router-tag other than a or area provided (#5107)
Co-authored-by: Jacob Müller
1 parent 404d6e8 commit 33c6cef

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/components/link/link.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,23 +149,19 @@ export const BLink = /*#__PURE__*/ Vue.extend({
149149
}
150150
},
151151
render(h) {
152+
const { active, disabled, target, routerTag, isRouterLink } = this
152153
const tag = this.computedTag
153154
const rel = this.computedRel
154155
const href = this.computedHref
155-
const isRouterLink = this.isRouterLink
156156

157157
const componentData = {
158-
class: { active: this.active, disabled: this.disabled },
158+
class: { active, disabled },
159159
attrs: {
160160
...this.$attrs,
161-
rel,
162-
target: this.target,
163-
tabindex: this.disabled
164-
? '-1'
165-
: isUndefined(this.$attrs.tabindex)
166-
? null
167-
: this.$attrs.tabindex,
168-
'aria-disabled': this.disabled ? 'true' : null
161+
// We don't render `rel` or `target` on non link tags when using `vue-router`
162+
...(isRouterLink && routerTag !== 'a' && routerTag !== 'area' ? {} : { rel, target }),
163+
tabindex: disabled ? '-1' : isUndefined(this.$attrs.tabindex) ? null : this.$attrs.tabindex,
164+
'aria-disabled': disabled ? 'true' : null
169165
},
170166
props: this.computedProps
171167
}

0 commit comments

Comments
 (0)
0