MCPcopy Index your code
hub / github.com/Alphanimble/htmlstream / initTableRowCountsFromTrack

Function initTableRowCountsFromTrack

src/patch-streaming-html.ts:995–1019  ·  view source on GitHub ↗
(
  container: HTMLElement,
  track: string,
)

Source from the content-addressed store, hash-verified

993
994/** Seed row counts from strip-only track (not DOM — avoids counting fallback partial rows) */
995export function initTableRowCountsFromTrack(
996 container: HTMLElement,
997 track: string,
998): void {
999 const table = container.querySelector("table");
1000 if (!table) {
1001 return;
1002 }
1003
1004 const tableStart = findTableStart(track);
1005 if (tableStart === -1) {
1006 return;
1007 }
1008
1009 const tableEnd = firstCompleteTableEnd(track, tableStart);
1010 const tableSection =
1011 tableEnd === -1
1012 ? track.slice(tableStart)
1013 : track.slice(tableStart, tableEnd);
1014 const parts = splitTableStream(tableSection);
1015 table.dataset.shTheadRowCount = String(parts.theadComplete.length);
1016 table.dataset.shRowCount = String(parts.tbodyComplete.length);
1017 table.style.tableLayout = "fixed";
1018 table.dataset.shLayoutFixed = "1";
1019}
1020
1021/** Seed row counts after a full render so incremental patches stay in sync */
1022export function initTableRowCounts(container: HTMLElement): void {

Callers 2

seedTableCountsFunction · 0.90

Calls 3

findTableStartFunction · 0.85
firstCompleteTableEndFunction · 0.85
splitTableStreamFunction · 0.85

Tested by

no test coverage detected