i think $document is not optional here. the lifecycle events always have a document associated.