From 2d8d8fbc27f14f0aee4b27692ab1f30e4a8ed90f Mon Sep 17 00:00:00 2001 From: Bryan Brancotte Date: Thu, 6 May 2021 16:20:02 +0200 Subject: [PATCH] get or create div.tooltip, improving readability --- js/tree-reusable-d3.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/js/tree-reusable-d3.js b/js/tree-reusable-d3.js index 024b68b3..d1e2b18f 100644 --- a/js/tree-reusable-d3.js +++ b/js/tree-reusable-d3.js @@ -87,11 +87,8 @@ function interactive_tree() { .call(zoom); var vis = svg.append("svg:g"); - /* jshint -W014 */ - var tooltip = (d3.select("body").select("div.tooltip").empty() /* if no div.tooltip*/ - ?d3.select("body").append("div") /* then create one */ - :d3.select("body").select("div.tooltip") /* otherwise use existing div.tooltip */ - ) + var body = d3.select("body"); + var tooltip = (body.select("div.tooltip").empty() ? body.append("div") : body.select("div.tooltip")) .attr("class", "tooltip") .style("opacity", 0) .on("mouseover", function(d) {