Skip to content

Commit

Permalink
fix: consistently use data-link-type on generated links (#4731)
Browse files Browse the repository at this point in the history
  • Loading branch information
dontcallmedom authored Nov 26, 2024
1 parent 433cdaa commit 6ca4e1a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/dfn-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; // <a data-cite="SPEC"></a>
Expand Down
2 changes: 1 addition & 1 deletion src/core/xref.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/core/inlines-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions tests/spec/core/xref-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 6ca4e1a

Please sign in to comment.