Add opts appendDocument and exposeGlobal for convenience