perf(#4346): recycle stable DOM nodes during virtual-scroll measurement re-renders

# Conflicts:
#	static/ui.js
#	tests/test_issue4346_vscroll_footer_jitter.py
This commit is contained in:
Rod Boev committed 2026-06-23 02:54:28 -04:00
1 parent fa3d612a4e
commit 9c364d8498
2 files changed
+97 -11

No files matched your search

@@ -51,3 +51,55 @@ def test_js_try_finally_guards_class_removal():
assert remove_idx != -1, "missing classList.remove('vscroll-measuring')"
assert try_idx < finally_idx < remove_idx, \
"classList.remove must remain in the finally{} cleanup path"
def test_js_recycle_flag_exists():
"""ui.js declares the _msgNodeRecycleEnabled flag."""
assert '_msgNodeRecycleEnabled' in JS
def test_js_recycle_stash_exists():
"""ui.js declares the _recycleStash Map."""
assert '_recycleStash' in JS
def test_js_recycle_flag_set_in_virtual_render():
"""_scheduleMessageVirtualizedRender sets _msgNodeRecycleEnabled=true
before the compensate call and clears it in finally."""
fn_match = re.search(
r'function _scheduleMessageVirtualizedRender\(force\)\{(.+?)^(?=function )',
JS, re.DOTALL | re.MULTILINE
)
assert fn_match, "_scheduleMessageVirtualizedRender not found"
body = fn_match.group(1)
assert '_msgNodeRecycleEnabled=true' in body
finally_match = re.search(r'finally\{([^}]*)\}', body)
assert finally_match, "no finally block in _scheduleMessageVirtualizedRender"
assert '_msgNodeRecycleEnabled=false' in finally_match.group(1)
def test_js_stash_populated_before_wipe():
"""The recycleStash population loop appears before innerHTML='' in renderMessages."""
fn_match = re.search(
r'function renderMessages\(options\)\{(.+?)^(?=function )',
JS, re.DOTALL | re.MULTILINE
)
assert fn_match, "renderMessages not found"
body = fn_match.group(1)
stash_pos = body.find('_recycleStash.set(')
wipe_pos = body.find("inner.innerHTML='';")
assert stash_pos != -1, "_recycleStash.set not found in renderMessages"
assert wipe_pos != -1, "innerHTML wipe not found in renderMessages"
assert stash_pos < wipe_pos, "_recycleStash.set must appear before innerHTML=''"
def test_js_user_row_checks_stash():
"""The user-row creation block checks _recycleStash before createElement."""
fn_match = re.search(
r'function renderMessages\(options\)\{(.+?)^(?=function )',
JS, re.DOTALL | re.MULTILINE
)
assert fn_match, "renderMessages not found"
body = fn_match.group(1)
assert '_recycleStash.get(rawIdx)' in body, \
"user row block must check _recycleStash.get(rawIdx)"