From c65378c3a828429fd50c94dfb06e884d1286d8f5 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Sat, 19 Oct 2024 00:42:50 +0800 Subject: fix: check validity for DocLink --- src/dumbyUtils.mjs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/dumbyUtils.mjs b/src/dumbyUtils.mjs index 6a77548..40afbd3 100644 --- a/src/dumbyUtils.mjs +++ b/src/dumbyUtils.mjs @@ -218,10 +218,12 @@ export const createGeoLink = (link) => { * @param {HTMLElement} Elements contains anchor elements for doclinks */ export const createDocLink = link => { + const label = decodeURIComponent(link.href.split('#')[1]) + const selector = link.title.split('=>')[1] ?? label ? '#' + label : null + if (!selector) return false + link.classList.add('with-leader-line', 'doclink') link.lines = [] - const label = decodeURIComponent(link.href.split('#')[1]) - const selector = link.title.split('=>')[1] ?? '#' + label link.onmouseover = () => { const targets = document.querySelectorAll(selector) -- cgit v1.2.3-70-g09d2