Fix null pointer error with svg documents

This fixes the value documentElement returns when the document is an svg
document (or any other kind of xml document).

jsdom isn't really well equipped to handle non-html documents though.
While the script gets appended, it won't get loaded. To resolve that I
ventured deep into DOM land, however I don't have any clue how this is
supposed to work.