Inject $document rather than using document directly to make unit testing
easier.