From da2dc19bdb7e10c68998418ba9091210b6538b8f Mon Sep 17 00:00:00 2001 From: Zheng Haisen <34539829+woshichaorens@users.noreply.github.com> Date: Thu, 18 Jan 2024 14:49:46 +0800 Subject: [PATCH 1/2] Update srcdoc.html Fix the problem of opening a new tab when clicking on the a tag --- src/output/srcdoc.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/output/srcdoc.html b/src/output/srcdoc.html index 3700e80d..decf776f 100644 --- a/src/output/srcdoc.html +++ b/src/output/srcdoc.html @@ -102,8 +102,9 @@ return } } - - window.open(el.href, '_blank') + if(el.href){ + window.open(el.href, '_blank') + } }) send_ok() } catch (e) { From a6e91f1666101ddfa7106d464f7fa8c255ecde74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Thu, 18 Jan 2024 17:55:34 +0800 Subject: [PATCH 2/2] fix: no herf --- src/output/srcdoc.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/output/srcdoc.html b/src/output/srcdoc.html index decf776f..82d4d7db 100644 --- a/src/output/srcdoc.html +++ b/src/output/srcdoc.html @@ -89,7 +89,8 @@ el.hasAttribute('download') || el.getAttribute('rel') === 'external' || el.target || - el.href.startsWith('javascript:') + el.href.startsWith('javascript:') || + !el.href ) return @@ -102,9 +103,8 @@ return } } - if(el.href){ - window.open(el.href, '_blank') - } + + window.open(el.href, '_blank') }) send_ok() } catch (e) {