This commit is contained in:
Kovid Goyal 2023-04-20 07:18:48 +05:30
parent 81fe7d3180
commit 1ef173bca5
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 15 additions and 15 deletions

View File

@ -350,8 +350,8 @@ def run_rapydscript_tests():
setup_fake_protocol, setup_profile
)
must_use_qt()
setup_default_profile()
setup_fake_protocol()
setup_default_profile()
base = base_dir()
rapydscript_dir = os.path.join(base, 'src', 'pyj')

View File

@ -52,6 +52,16 @@ def get_current_time(target): # {{{
return fstr(target.currentTime or 0)
# }}}
def id_is_unique(idval): # {{{
try:
multiples = document.querySelectorAll('[id=' + window.CSS.escape(idval) + ']')
except:
return False
if multiples and multiples.length < 2:
return True
return False
# }}}
# Convert point to character offset {{{
def range_has_point(range_, x, y):
rects = range_.getClientRects()
@ -239,12 +249,7 @@ def encode(doc, node, offset, tail):
# Add id assertions for robustness where possible
id = node.id
idspec = ''
if id:
try:
multiples = document.querySelectorAll('#' + id)
except:
multiples = None
if multiples and multiples.length < 2:
if id and id_is_unique(id):
idspec = ('[' + escape_for_cfi(id) + ']')
cfi = '/' + index + idspec + cfi
node = p
@ -274,12 +279,7 @@ def node_at_index(nodes, target, index, iter_text_nodes):
def node_for_path_step(parent, target, assertion):
if assertion:
q = document.getElementById(assertion)
if q:
try:
multiples = document.querySelectorAll('#' + assertion)
except:
multiples = None
if multiples and multiples.length < 2:
if q and id_is_unique(assertion):
return q
is_element = target % 2 == 0
target //= 2