* Creates DOM to represent a table, similar to what'd be generated * during the SSR.
(data: TableCell[][])
| 87 | * during the SSR. |
| 88 | */ |
| 89 | function createTableDom(data: TableCell[][]) { |
| 90 | const table = document.createElement('table'); |
| 91 | const tbody = document.createElement('tbody'); |
| 92 | table.appendChild(tbody); |
| 93 | for (let r = 0; r < data.length; r++) { |
| 94 | const dataRow = data[r]; |
| 95 | const tr = document.createElement('tr'); |
| 96 | // Mark created DOM nodes, so that we can verify that |
| 97 | // they were *not* re-created during hydration. |
| 98 | (tr as any).__existing = true; |
| 99 | tbody.appendChild(tr); |
| 100 | const renderRow = []; |
| 101 | for (let c = 0; c < dataRow.length; c++) { |
| 102 | const dataCell = dataRow[c]; |
| 103 | const renderCell = document.createElement('td'); |
| 104 | // Mark created DOM nodes, so that we can verify that |
| 105 | // they were *not* re-created during hydration. |
| 106 | (renderCell as any).__existing = true; |
| 107 | if (r % 2 === 0) { |
| 108 | renderCell.style.backgroundColor = 'grey'; |
| 109 | } |
| 110 | tr.appendChild(renderCell); |
| 111 | renderRow[c] = renderCell; |
| 112 | renderCell.textContent = dataCell.value; |
| 113 | } |
| 114 | // View container anchor |
| 115 | const comment = document.createComment(''); |
| 116 | tr.appendChild(comment); |
| 117 | } |
| 118 | // View container anchor |
| 119 | const comment = document.createComment(''); |
| 120 | tbody.appendChild(comment); |
| 121 | return table; |
| 122 | } |
no test coverage detected
searching dependent graphs…