From ad9d1b4d120c58e00659d9c81f18406cb1a73b9d Mon Sep 17 00:00:00 2001 From: woshiguabi Date: Thu, 21 Oct 2021 18:54:58 +0800 Subject: [PATCH] fix: Cannot read property 'tagName' of null MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/core/router/history/html5.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/router/history/html5.js b/src/core/router/history/html5.js index 28fa2ea27..eeadb1af1 100644 --- a/src/core/router/history/html5.js +++ b/src/core/router/history/html5.js @@ -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