fix crash on amazon product page

This commit is contained in:
Karl Seguin
2025-12-24 08:00:26 +08:00
parent 9969ff7165
commit 7183b0339b
2 changed files with 12 additions and 1 deletions

View File

@@ -153,3 +153,11 @@
}
</script>
<script id=list_caching>
{
// this ordering used to crash
const list = document.getElementsByTagName('div');
testing.expectEqual('0', list[0].textContent);
testing.expectEqual(3, list.length);
}
</script>

View File

@@ -114,8 +114,11 @@ pub fn NodeLive(comptime mode: Mode) type {
if (self._last_length) |cached_length| {
return cached_length;
}
// not ideal, but this can happen if list[x] is called followed
// by list.length.
self._tw.reset();
self._last_index = 0;
}
// If we're here, it means it's either the first time we're called
// or the DOM version has changed. Either way, the _tw should be
// at the start position. It's important that self._last_index == 0