Add check in splitCells to prevent calling trim on undefined (#2372)

This commit is contained in:
Zach Bialecki 2022-01-26 23:07:01 -05:00 committed by GitHub
parent 83753142a1
commit ed66bf8abd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 1 deletions

View File

@ -162,7 +162,7 @@ export function splitCells(tableRow, count) {
// First/last cell in a row cannot be empty if it has no leading/trailing pipe
if (!cells[0].trim()) { cells.shift(); }
if (!cells[cells.length - 1].trim()) { cells.pop(); }
if (cells.length > 0 && !cells[cells.length - 1].trim()) { cells.pop(); }
if (cells.length > count) {
cells.splice(count);

View File

@ -0,0 +1,22 @@
<table>
<thead>
<tr>
<th>abc</th>
<th>def</th>
</tr>
</thead>
<tbody>
<tr>
<td>bar</td>
<td>foo</td>
</tr>
<tr>
<td>baz</td>
<td>boo</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,5 @@
| abc | def |
| --- | --- |
| bar | foo |
| baz | boo |