Skip to content

Commit ed66bf8

Browse files
authored
Add check in splitCells to prevent calling trim on undefined (#2372)
1 parent 8375314 commit ed66bf8

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export function splitCells(tableRow, count) {
162162

163163
// First/last cell in a row cannot be empty if it has no leading/trailing pipe
164164
if (!cells[0].trim()) { cells.shift(); }
165-
if (!cells[cells.length - 1].trim()) { cells.pop(); }
165+
if (cells.length > 0 && !cells[cells.length - 1].trim()) { cells.pop(); }
166166

167167
if (cells.length > count) {
168168
cells.splice(count);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<table>
2+
<thead>
3+
<tr>
4+
<th>abc</th>
5+
<th>def</th>
6+
</tr>
7+
</thead>
8+
<tbody>
9+
<tr>
10+
<td>bar</td>
11+
<td>foo</td>
12+
</tr>
13+
<tr>
14+
<td>baz</td>
15+
<td>boo</td>
16+
</tr>
17+
<tr>
18+
<td></td>
19+
<td></td>
20+
</tr>
21+
</tbody>
22+
</table>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
| abc | def |
2+
| --- | --- |
3+
| bar | foo |
4+
| baz | boo |
5+
 

0 commit comments

Comments
 (0)