From 6e6ca80d6215e60f116f97ddcdae39890a4ea065 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 19 Aug 2024 09:44:31 +0530 Subject: [PATCH] Fix #2077283 [Private bug](https://bugs.launchpad.net/calibre/+bug/2077283) (probably) --- src/pyj/range_utils.pyj | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pyj/range_utils.pyj b/src/pyj/range_utils.pyj index a69a1116ec..540f3f9a63 100644 --- a/src/pyj/range_utils.pyj +++ b/src/pyj/range_utils.pyj @@ -240,21 +240,19 @@ def reset_highlight_counter(): def get_annot_id_for(node, offset, annot_id_uuid_map): - if not node: return if node.nodeType is Node.ELEMENT_NODE: if node.dataset.calibreRangeWrapper: return annot_id_uuid_map[node.dataset.calibreRangeWrapper] if offset is 0: - - if node.firstChild?.nodeType is Node.ELEMENT_NODE and node.firstChild.dataset.calibreRangeWrapper: + if node.firstChild?.nodeType is Node.ELEMENT_NODE and node.firstChild.dataset?.calibreRangeWrapper: return annot_id_uuid_map[node.firstChild.dataset.calibreRangeWrapper] elif offset < node.childNodes.length: node = node.childNodes[offset] return get_annot_id_for(node, 0, annot_id_uuid_map) elif node.nodeType is Node.TEXT_NODE: - if node.parentNode?.nodeType is Node.ELEMENT_NODE and node.parentNode.dataset.calibreRangeWrapper: + if node.parentNode?.nodeType is Node.ELEMENT_NODE and node.parentNode.dataset?.calibreRangeWrapper: return annot_id_uuid_map[node.parentNode.dataset.calibreRangeWrapper]