FB2: fix handling of non-element nodes

This commit is contained in:
John Factotum
2022-11-10 13:59:23 +00:00
committed by GitHub
parent b6f514675b
commit d76027c00a
+3 -1
View File
@@ -112,7 +112,9 @@ class FB2Converter {
}
convert(node, def) {
// not an element; return text content
if (node.nodeType !== 1) return this.doc.createTextNode(node.textContent)
if (node.nodeType === 3) return this.doc.createTextNode(node.textContent)
if (node.nodeType === 4) return this.doc.createCDATASection(node.textContent)
if (node.nodeType === 8) return this.doc.createComment(node.textContent)
const d = def?.[node.nodeName]
if (!d) return null