Using the global document as a default is very error prone since people will just not pass the document in, and it will work during development because during development there usually is only a single document, which is the global one, and once it goes to production, to people that use multiple documents (in iframes) everything will break. Please don't use a default document.