aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/dumbyUtils.mjs
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-10-19 00:42:50 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-10-19 00:42:50 +0800
commitc65378c3a828429fd50c94dfb06e884d1286d8f5 (patch)
tree90852a960eec60b58b15e3fd84a4a568e6c98b33 /src/dumbyUtils.mjs
parente55078e5cb4a5bdcbecc01a33c00e45afca7db17 (diff)
fix: check validity for DocLink
Diffstat (limited to 'src/dumbyUtils.mjs')
-rw-r--r--src/dumbyUtils.mjs6
1 files 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) => {
218 * @param {HTMLElement} Elements contains anchor elements for doclinks 218 * @param {HTMLElement} Elements contains anchor elements for doclinks
219 */ 219 */
220export const createDocLink = link => { 220export const createDocLink = link => {
221 const label = decodeURIComponent(link.href.split('#')[1])
222 const selector = link.title.split('=>')[1] ?? label ? '#' + label : null
223 if (!selector) return false
224
221 link.classList.add('with-leader-line', 'doclink') 225 link.classList.add('with-leader-line', 'doclink')
222 link.lines = [] 226 link.lines = []
223 const label = decodeURIComponent(link.href.split('#')[1])
224 const selector = link.title.split('=>')[1] ?? '#' + label
225 227
226 link.onmouseover = () => { 228 link.onmouseover = () => {
227 const targets = document.querySelectorAll(selector) 229 const targets = document.querySelectorAll(selector)