Skip to content

Commit 2f26416

Browse files
authored
use the context’s document to create the input Event (#2169)
closes #2159
1 parent 09edfec commit 2f26416

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/plot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export function plot(options = {}) {
175175
context.dispatchValue = (value) => {
176176
if (figure.value === value) return;
177177
figure.value = value;
178-
figure.dispatchEvent(new Event("input", {bubbles: true}));
178+
figure.dispatchEvent(new context.document.defaultView.Event("input", {bubbles: true}));
179179
};
180180

181181
// Reinitialize; for deriving channels dependent on other channels.

test/event-test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import * as Plot from "@observablehq/plot";
2+
import * as assert from "assert";
3+
import {JSDOM} from "jsdom";
4+
5+
it("Plot uses the context’s event", () => {
6+
Plot.lineY([1, 2, 3], {tip: true}).plot({document: new JSDOM("").window.document});
7+
assert.ok(true);
8+
});

0 commit comments

Comments
 (0)