From 1a879369fd373bda3c0cf9029d6670f8c334c060 Mon Sep 17 00:00:00 2001 From: Alasdair McLeay Date: Fri, 27 Jan 2023 11:35:44 +0000 Subject: [PATCH] Support d3.drag in testing environments Return early from nodrag if no view is passed. Fixes #89 --- src/nodrag.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/nodrag.js b/src/nodrag.js index 6076694..35e9c84 100644 --- a/src/nodrag.js +++ b/src/nodrag.js @@ -2,6 +2,9 @@ import {select} from "d3-selection"; import noevent, {nonpassivecapture} from "./noevent.js"; export default function(view) { + if (!view) { + return; + } var root = view.document.documentElement, selection = select(view).on("dragstart.drag", noevent, nonpassivecapture); if ("onselectstart" in root) {