Skip to content

Commit 0157ad0

Browse files
committed
only update href if element is anchor
1 parent 1f6888f commit 0157ad0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/directives/link.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ export default function (Vue) {
118118
},
119119

120120
updateHref () {
121+
if (this.el.tagName !== 'A') {
122+
return
123+
}
121124
if (this.target && this.target.name) {
122125
this.el.href = '#' + this.target.name
123126
return
@@ -129,12 +132,10 @@ export default function (Vue) {
129132
const href = path && (router.mode === 'hash' || isAbsolute)
130133
? router.history.formatPath(path, this.append)
131134
: path
132-
if (this.el.tagName === 'A') {
133-
if (href) {
134-
this.el.href = href
135-
} else {
136-
this.el.removeAttribute('href')
137-
}
135+
if (href) {
136+
this.el.href = href
137+
} else {
138+
this.el.removeAttribute('href')
138139
}
139140
},
140141

0 commit comments

Comments
 (0)