Skip to content

Commit

Permalink
fix: Cannot read property 'tagName' of null
Browse files Browse the repository at this point in the history
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
  • Loading branch information
woshiguabi authored Oct 21, 2021
1 parent d16e657 commit ad9d1b4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/router/history/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class HTML5History extends History {
on('click', e => {
const el = e.target.tagName === 'A' ? e.target : e.target.parentNode;

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

0 comments on commit ad9d1b4

Please sign in to comment.