Only attach events if there is a document available
1.4.0