Use DOM tree for events dispatched on document

The document and window were being treated as non-DOM targets. This
meant that the document was being asked for it's nextTarget meaning
listeners on the window for document dispatched events would never
receive the event.