[fix] Allow a custom `document` option so this can be used within diff contexts