From 5441a4194c2b011a433075e5790b2bd19f74f82d Mon Sep 17 00:00:00 2001 From: 2betop <2betop.cn@gmail.com> Date: Tue, 25 May 2021 20:02:09 +0800 Subject: [PATCH] =?UTF-8?q?data-link=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderers/Page.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/renderers/Page.tsx b/src/renderers/Page.tsx index b50a6143d..9945c99df 100644 --- a/src/renderers/Page.tsx +++ b/src/renderers/Page.tsx @@ -348,9 +348,13 @@ export default class Page extends React.Component { handleClick(e: any) { const target: HTMLElement = e.target as HTMLElement; const {env} = this.props; + const link = + target.tagName === 'A' && target.hasAttribute('data-link') + ? target.getAttribute('data-link') + : target.closest('a[data-link]')?.getAttribute('data-link'); - if (env && target.tagName === 'A' && target.hasAttribute('data-link')) { - env.jumpTo(target.getAttribute('data-link') as string); + if (env && link) { + env.jumpTo(link); e.preventDefault(); } }