From 95784fa0d0dd94b5558c52fa0e8f746f5cfcddbc Mon Sep 17 00:00:00 2001 From: makhnatkin Date: Fri, 27 Jun 2025 12:48:56 +0200 Subject: [PATCH] fix(view): support anchor links using name instead of id --- src/view/hooks/useYfmShowElemWithId/useYfmShowElemWithId.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view/hooks/useYfmShowElemWithId/useYfmShowElemWithId.ts b/src/view/hooks/useYfmShowElemWithId/useYfmShowElemWithId.ts index 76ea767e8..34770b694 100644 --- a/src/view/hooks/useYfmShowElemWithId/useYfmShowElemWithId.ts +++ b/src/view/hooks/useYfmShowElemWithId/useYfmShowElemWithId.ts @@ -26,7 +26,7 @@ export function useYfmShowElemWithId(ref: RefObject, id: string) { const {current: containerDom} = ref; if (!id || !containerDom) return; - let elem = document.getElementById(id); + let elem = document.getElementById(id) ?? document.querySelector(`[name="${id}"]`); if (!elem || !containerDom.contains(elem)) return; while (elem && elem !== containerDom) {