SAXParseException when trying to add an unclosed, raw `<link>` tag into a `head { ... }` block
bitspittle opened this issue · 4 comments
bitspittle commented
Specifically, org.xml.sax.SAXParseException; The element type "link" must be terminated by the matching end-tag "</link>".
Expected: kotlinx.html
can receive unclosed <link>
tags in the <head>
element.
Actual: The <link>
element, which is a void element and does not have to close in valid html (and in fact is how kotlinx.html
generates it) is getting triggered with a parse exception by kotlinx.html
Repro steps
Here's a very simple example to show the issue:
println(createHTML().head {
link {
rel = "stylesheet"
href = "https://example.com/fake.css"
}
})
which outputs:
<head>
<link rel="stylesheet" href="https://example.com/fake.css">
</head>
Writing the kotlinx.html code to represent that...
document {
append {
head {
unsafe {
+"<link rel=\"stylesheet\" href=\"https://example.com/fake.css\">"
}
}
}
}
results in the unexpected stack trace:
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 74; The element type "link" must be terminated by the matching end-tag "</link>".
at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:261)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
at kotlinx.html.dom.HTMLDOMBuilder$UnsafeImpl$1.unaryPlus(dom-jvm.kt:98)
at ...