Summary
Document.compatMode is missing (undefined) on happy-dom documents.
Browsers expose either "CSS1Compat" (standards) or "BackCompat" (quirks). Libraries such as KaTeX treat anything other than "CSS1Compat" as quirks mode and emit:
Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype.
Repro
import { Window } from 'happy-dom'
const window = new Window({ url: 'http://localhost/' })
console.log(window.document.compatMode) // → undefined (expected: "CSS1Compat" or "BackCompat")
window.document.write('<!DOCTYPE html><html><head></head><body></body></html>')
console.log(window.document.compatMode) // still undefined even with a doctype present
Seen with happy-dom@15 under Deno.
Suggested fix
Implement Document.compatMode per HTML / DOM:
"CSS1Compat" when the document has an HTML doctype (or is XML)
"BackCompat" otherwise
Happy to test a PR.
Consumer note (steve02081504/fount): Markdown pure tests shim compatMode to 'CSS1Compat' until this lands; remove that override after a happy-dom release that implements it.
Summary
Document.compatModeis missing (undefined) on happy-dom documents.Browsers expose either
"CSS1Compat"(standards) or"BackCompat"(quirks). Libraries such as KaTeX treat anything other than"CSS1Compat"as quirks mode and emit:Repro
Seen with
happy-dom@15under Deno.Suggested fix
Implement
Document.compatModeper HTML / DOM:"CSS1Compat"when the document has an HTML doctype (or is XML)"BackCompat"otherwiseHappy to test a PR.
Consumer note (steve02081504/fount): Markdown pure tests shim
compatModeto'CSS1Compat'until this lands; remove that override after a happy-dom release that implements it.