Skip to content

Commit 3079054

Browse files
authored
fix(view): support anchor links using name instead of id (#792)
1 parent 04a7fab commit 3079054

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/view/hooks/useYfmShowElemWithId/useYfmShowElemWithId.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function useYfmShowElemWithId(ref: RefObject<HTMLElement>, id: string) {
2626
const {current: containerDom} = ref;
2727
if (!id || !containerDom) return;
2828

29-
let elem = document.getElementById(id);
29+
let elem = document.getElementById(id) ?? document.querySelector(`[name="${id}"]`);
3030
if (!elem || !containerDom.contains(elem)) return;
3131

3232
while (elem && elem !== containerDom) {

0 commit comments

Comments
 (0)