[fix] Don't assume that the `document` global exists