MCPcopy Create free account
hub / github.com/Alphanimble/htmlstream / patchPartialRowInSection

Function patchPartialRowInSection

src/patch-streaming-html.ts:822–850  ·  view source on GitHub ↗
(
  section: HTMLTableSectionElement,
  partial: string,
  completeRowCount: number,
)

Source from the content-addressed store, hash-verified

820}
821
822function patchPartialRowInSection(
823 section: HTMLTableSectionElement,
824 partial: string,
825 completeRowCount: number,
826): void {
827 const marked = markPartialRow(autoCloseFragment(partial));
828
829 let partialTr = section.querySelector("tr[data-sh-partial]");
830 if (!partialTr) {
831 partialTr = findInProgressRow(section, completeRowCount);
832 }
833
834 if (!partialTr) {
835 if (completeRowCount === 0) {
836 // Malformed tables often emit multiple <tr> without </tr> — keep one partial row.
837 section.querySelectorAll("tr").forEach((tr) => tr.remove());
838 insertSafeHtml(section, "beforeend", marked);
839 return;
840 }
841 insertSafeHtml(section, "beforeend", marked);
842 return;
843 }
844
845 const prevHeight = partialTr.getBoundingClientRect().height;
846 if (prevHeight > 0) {
847 (partialTr as HTMLElement).style.minHeight = `${prevHeight}px`;
848 }
849 partialTr.outerHTML = sanitizePatchFragment(marked);
850}
851
852/** Reuse the streaming partial row when the track has no complete rows yet. */
853function findInProgressRow(

Callers 1

patchTableRowsFunction · 0.85

Calls 5

markPartialRowFunction · 0.85
autoCloseFragmentFunction · 0.85
findInProgressRowFunction · 0.85
insertSafeHtmlFunction · 0.85
sanitizePatchFragmentFunction · 0.85

Tested by

no test coverage detected