mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Treat XHTML without xmlns as HTML
The XHTML 1.1 spec says
The start tag of the root element of the document MUST explicitly
contain an xmlns declaration for the XHTML namespace
There doesn't seem to be such a requirement in the WHATWG spec. But at
any rate browsers won't render it properly without the XHTML namespace.
This commit is contained in:
@@ -673,8 +673,9 @@ class Loader {
|
||||
if ([MIME.XHTML, MIME.HTML, MIME.SVG].includes(mediaType)) {
|
||||
let doc = new DOMParser().parseFromString(str, mediaType)
|
||||
// change to HTML if it's not valid XHTML
|
||||
if (mediaType === MIME.XHTML && doc.querySelector('parsererror')) {
|
||||
console.warn(doc.querySelector('parsererror').innerText)
|
||||
if (mediaType === MIME.XHTML && (doc.querySelector('parsererror')
|
||||
|| !doc.documentElement?.namespaceURI)) {
|
||||
console.warn(doc.querySelector('parsererror')?.innerText ?? 'Invalid XHTML')
|
||||
item.mediaType = MIME.HTML
|
||||
doc = new DOMParser().parseFromString(str, item.mediaType)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user