Skip to content

Commit c3cdadc

Browse files
fix: Cannot read property 'tagName' of null (#1655)
Have a look at this issue #1154 . https://codesandbox.io/s/loving-matsumoto-hp985?file=/index.html Open devtools and click the *blank space* of svg(not path) will reproduce this issue. `parentNode` may be `null`. https://github.com/docsifyjs/docsify/blob/develop/src/core/router/history/html5.js#L25-L27 However, hash router has fixed this issue😜. https://github.com/docsifyjs/docsify/blob/develop/src/core/router/history/hash.js#L47-L49 Co-authored-by: 沈唁 <[email protected]>
1 parent 57dc8a9 commit c3cdadc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: src/core/router/history/html5.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class HTML5History extends History {
2424
on('click', e => {
2525
const el = e.target.tagName === 'A' ? e.target : e.target.parentNode;
2626

27-
if (el.tagName === 'A' && !/_blank/.test(el.target)) {
27+
if (el && el.tagName === 'A' && !/_blank/.test(el.target)) {
2828
e.preventDefault();
2929
const url = el.href;
3030
// solve history.pushState cross-origin issue

0 commit comments

Comments
 (0)