Document.activeElement is currently defined to return the <body> element if there is not element with focus, or null if there's no <body> element. I think it needs to return the root element when the document isn't an HTML document (like an SVG document).