From 6ca4e1a55dfbd80b4ad50355f1df158ca8de7aa2 Mon Sep 17 00:00:00 2001 From: Dominique Hazael-Massieux Date: Tue, 26 Nov 2024 09:48:49 +0100 Subject: [PATCH] fix: consistently use `data-link-type` on generated links (#4731) --- src/core/dfn-index.js | 2 +- src/core/xref.js | 2 +- tests/spec/core/inlines-spec.js | 2 +- tests/spec/core/xref-spec.js | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/dfn-index.js b/src/core/dfn-index.js index d4439f0f9d..573718e525 100644 --- a/src/core/dfn-index.js +++ b/src/core/dfn-index.js @@ -277,7 +277,7 @@ function collectExternalTerms() { continue; } - const { type, linkFor } = elem.dataset; + const { linkType: type, linkFor } = elem.dataset; const term = getTermFromElement(elem); if (!term) { continue; // diff --git a/src/core/xref.js b/src/core/xref.js index 6bc80ea7f4..9e4c5af886 100644 --- a/src/core/xref.js +++ b/src/core/xref.js @@ -405,7 +405,7 @@ function addDataCite(elem, query, result, conf) { // a filename. That filename must be preserved if there's no specific path. if (citePath === "/") citePath = ""; const citeFrag = url.hash.slice(1); - const dataset = { cite, citePath, citeFrag, type }; + const dataset = { cite, citePath, citeFrag, linkType: type }; if (forContext) dataset.linkFor = forContext[0]; if (url.origin && url.origin !== "https://partial") { dataset.citeHref = url.href; diff --git a/tests/spec/core/inlines-spec.js b/tests/spec/core/inlines-spec.js index a08815174c..ed8b132daf 100644 --- a/tests/spec/core/inlines-spec.js +++ b/tests/spec/core/inlines-spec.js @@ -623,7 +623,7 @@ describe("Core - Inlines", () => { expect(primitiveAnchor.hash).toBe("#idl-unsigned-short"); const primitiveData = primitiveAnchor.dataset; - expect(primitiveData.linkType).toBe("idl"); + expect(primitiveData.linkType).toBe("interface"); expect(primitiveData.cite).toBe("webidl"); expect(primitiveData.xrefType).toBe("interface"); expect(primitiveData.lt).toBe("unsigned short"); diff --git a/tests/spec/core/xref-spec.js b/tests/spec/core/xref-spec.js index 0c13a7338f..1cfaabf0ac 100644 --- a/tests/spec/core/xref-spec.js +++ b/tests/spec/core/xref-spec.js @@ -77,6 +77,7 @@ describe("Core — xref", () => { expect(link.href).toBe( "https://html.spec.whatwg.org/multipage/webappapis.html#event-handlers" ); + expect(link.dataset.linkType).toBe("dfn"); expect(link.classList.contains("respec-offending-element")).toBeFalsy(); const dfn = doc.querySelector("#external-dfn dfn a");