( section: HTMLTableSectionElement, partial: string, completeRowCount: number, )
| 820 | } |
| 821 | |
| 822 | function 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. */ |
| 853 | function findInProgressRow( |
no test coverage detected