Prevent Table from Disappearing due to exception when looking for tHead (#13680)

* Prevent exception when tHead doesn't exist at node

* Add test for no thead
This commit is contained in:
Chris LaFreniere
2020-12-04 14:42:24 -08:00
committed by GitHub
parent 0c82024cf3
commit 6349f1bd49
2 changed files with 8 additions and 2 deletions

View File

@@ -99,12 +99,12 @@ rules['table'] = {
// Ensure there are no blank lines
content = content.replace('\n\n', '\n');
// if the headings are empty, add border line and headings to keep table format
if (node.tHead.innerText === '') {
if (node.tHead?.innerText === '') {
let emptyHeader = '\n\n|';
let border = '\n|';
for (let i = 0; i < node.rows[0].childNodes.length; i++) {
emptyHeader += ' |';
border += ' --- |'
border += ' --- |';
}
return emptyHeader + border + content + '\n\n';
}