Better fix for anchors that dont yield elements

This commit is contained in:
Kovid Goyal 2024-08-26 21:38:47 +05:30
parent 6f59dfba54
commit ab9a27f6fd
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -36,7 +36,14 @@ def position_for_anchor(anchor, is_page_list_anchor):
if val?:
return val
anchor_funcs = get_boss().anchor_funcs
if anchor:
elem = document.getElementById(anchor)
if not elem:
q = document.getElementsByName(anchor)
if q and q.length:
elem = q[0]
else:
elem = document.body
if is_page_list_anchor:
ensure_page_list_target_is_displayed(elem)
val = anchor_funcs.pos_for_elem(elem) if elem else anchor_funcs.pos_for_elem()