This commit is contained in:
Vanessa 2022-09-23 17:18:51 +08:00
parent 15676b2433
commit 968cc47df2

View file

@ -258,7 +258,15 @@ export class Preview {
private processZHTable(element: HTMLElement) {
element.querySelectorAll("table").forEach(item => {
const headElement = item.querySelector("thead");
item.querySelector("tbody").insertAdjacentElement("afterbegin", headElement.firstElementChild);
if (!headElement) {
return;
}
const tbodyElement = item.querySelector("tbody");
if (tbodyElement) {
tbodyElement.insertAdjacentElement("afterbegin", headElement.firstElementChild);
} else {
item.innerHTML = `<tbody>${headElement.innerHTML}</tbody>`;
}
headElement.remove();
});
}