Skip to content

Commit e43fdc6

Browse files
AnthonySendraposva
authored andcommitted
fix .getAttribute on an object without this method (#967)
1 parent af78335 commit e43fdc6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/components/link.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ function guardEvent (e) {
9494
if (e.button !== 0) return
9595
// don't redirect if `target="_blank"`
9696
/* istanbul ignore if */
97-
const target = e.target.getAttribute('target')
98-
if (/\b_blank\b/i.test(target)) return
97+
if (e.target && e.target.getAttribute) {
98+
const target = e.target.getAttribute('target')
99+
if (/\b_blank\b/i.test(target)) return
100+
}
99101

100102
e.preventDefault()
101103
return true

0 commit comments

Comments
 (0)