Skip to content

fix: Cannot read property 'tagName' of null #1655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 22, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: Cannot read property 'tagName' of null
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
commit ad9d1b4d120c58e00659d9c81f18406cb1a73b9d
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