diff --git a/src/plot.js b/src/plot.js index 9fc6a3e138..a7383a66c7 100644 --- a/src/plot.js +++ b/src/plot.js @@ -175,7 +175,7 @@ export function plot(options = {}) { context.dispatchValue = (value) => { if (figure.value === value) return; figure.value = value; - figure.dispatchEvent(new Event("input", {bubbles: true})); + figure.dispatchEvent(new context.document.defaultView.Event("input", {bubbles: true})); }; // Reinitialize; for deriving channels dependent on other channels. diff --git a/test/event-test.js b/test/event-test.js new file mode 100644 index 0000000000..2b0c1d0e2f --- /dev/null +++ b/test/event-test.js @@ -0,0 +1,8 @@ +import * as Plot from "@observablehq/plot"; +import * as assert from "assert"; +import {JSDOM} from "jsdom"; + +it("Plot uses the context’s event", () => { + Plot.lineY([1, 2, 3], {tip: true}).plot({document: new JSDOM("").window.document}); + assert.ok(true); +});