Dont use zero offset for element selections

This commit is contained in:
Kovid Goyal 2020-07-24 08:16:52 +05:30
parent 366a69a3cd
commit d2db909851
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -793,7 +793,7 @@ def cfi_for_selection(r): # {{{
nt = container.nodeType
if nt is Node.TEXT_NODE or nt is Node.CDATA_SECTION_NODE or nt is Node.COMMENT_NODE:
return container, offset
if nt is Node.ELEMENT_NODE:
if nt is Node.ELEMENT_NODE and offset and container.childNodes.length > offset:
return container.childNodes[offset], 0
return container, offset