From 63700881df91fbcaef56ce8c65fbfd4f4918efc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Rivi=C3=A8re?= Date: Tue, 14 Jun 2022 14:34:00 +0200 Subject: [PATCH] visited links color fixes #935 --- src/style.js | 1 + test/output/documentationLinks.svg | 50 +++++++++++++++--------------- test/output/hrefFill.svg | 27 ++++++++++++++++ test/plots/href-fill.js | 11 +++++++ test/plots/index.js | 1 + 5 files changed, 65 insertions(+), 25 deletions(-) create mode 100644 test/output/hrefFill.svg create mode 100644 test/plots/href-fill.js diff --git a/src/style.js b/src/style.js index 4fc0804dff..4df2b7c7f7 100644 --- a/src/style.js +++ b/src/style.js @@ -288,6 +288,7 @@ function applyHref(selection, href, target) { const h = href(i); if (h != null) { const a = document.createElementNS(namespaces.svg, "a"); + a.setAttribute("fill", "inherit"); a.setAttributeNS(namespaces.xlink, "href", h); if (target != null) a.setAttribute("target", target); this.parentNode.insertBefore(a, this).appendChild(this); diff --git a/test/output/documentationLinks.svg b/test/output/documentationLinks.svg index 9ba7095783..558a76c4b7 100644 --- a/test/output/documentationLinks.svg +++ b/test/output/documentationLinks.svg @@ -128,55 +128,55 @@ 40 likes → - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + ⚡︎ 296 16 18 6 10 3 9 17 5 11 8 2 2 4 5 1 3 7 12 13 6 3 6 7 18 diff --git a/test/output/hrefFill.svg b/test/output/hrefFill.svg new file mode 100644 index 0000000000..970b7d26c1 --- /dev/null +++ b/test/output/hrefFill.svg @@ -0,0 +1,27 @@ + + + + + 0 + + + + + 0 + + + click me + \ No newline at end of file diff --git a/test/plots/href-fill.js b/test/plots/href-fill.js new file mode 100644 index 0000000000..3a448212e1 --- /dev/null +++ b/test/plots/href-fill.js @@ -0,0 +1,11 @@ +import * as Plot from "@observablehq/plot"; + +export default async function() { + return Plot.text({length: 1}, { + text: ["click me"], + x: 0, + y: 0, + fill: "red", + href: [`https://google.com/search?q=12345`] + }).plot(); +} diff --git a/test/plots/index.js b/test/plots/index.js index 0caa616fdf..364a7b601a 100644 --- a/test/plots/index.js +++ b/test/plots/index.js @@ -86,6 +86,7 @@ export {default as hexbinText} from "./hexbin-text.js"; export {default as hexbinZ} from "./hexbin-z.js"; export {default as hexbinZNull} from "./hexbin-z-null.js"; export {default as highCardinalityOrdinal} from "./high-cardinality-ordinal.js"; +export {default as hrefFill} from "./href-fill.js"; export {default as identityScale} from "./identity-scale.js"; export {default as integerInterval} from "./integer-interval.js"; export {default as ibmTrading} from "./ibm-trading.js";