This commit is contained in:
Kovid Goyal 2019-12-19 18:27:59 +05:30
parent 8ce99d51c7
commit a0420c9820
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -230,8 +230,9 @@ def process_stack(stack, tag_map, ns_map, load_required, onload):
break break
if loadable: if loadable:
load_required.add(tag_id) load_required.add(tag_id)
elem.addEventListener('load', onload.bind(tag_id)) load_callback = onload.bind(tag_id)
elem.addEventListener('error', onload.bind(tag_id)) elem.addEventListener('load', load_callback)
elem.addEventListener('error', load_callback)
apply_attributes(src, elem, ns_map) apply_attributes(src, elem, ns_map)
parent.appendChild(elem) parent.appendChild(elem)
@ -286,13 +287,13 @@ def unserialize_html(serialized_data, proceed, postprocess_dom, root_name):
nonlocal proceeded nonlocal proceeded
if not proceeded: if not proceeded:
proceeded = True proceeded = True
print('WARNING: All resources did not load in {} seconds, proceeding anyway ({} resources left)'.format(hang_timeout, load_required.length)) print(f'WARNING: All resources did not load in {hang_timeout} seconds, proceeding anyway ({load_required.length} resources left)')
proceed() proceed()
def onload(): def onload():
nonlocal proceeded nonlocal proceeded
load_required.discard(this) load_required.discard(this)
if not load_required.length: if not load_required.length and not proceeded:
proceeded = True proceeded = True
proceed() proceed()
@ -368,13 +369,13 @@ def unserialize_html_legacy(serialized_data, proceed, postprocess_dom, root_name
nonlocal proceeded nonlocal proceeded
if not proceeded: if not proceeded:
proceeded = True proceeded = True
print('WARNING: All resources did not load in {} seconds, proceeding anyway ({} resources left)'.format(hang_timeout, load_required.length)) print(f'WARNING: All resources did not load in {hang_timeout} seconds, proceeding anyway ({load_required.length} resources left)')
proceed() proceed()
def onload(): def onload():
nonlocal proceeded nonlocal proceeded
load_required.discard(this) load_required.discard(this)
if not load_required.length: if not load_required.length and not proceeded:
proceeded = True proceeded = True
proceed() proceed()