diff --git a/src/core/inlines.js b/src/core/inlines.js index 71f8308b98..e0278b28d5 100644 --- a/src/core/inlines.js +++ b/src/core/inlines.js @@ -145,9 +145,9 @@ function inlineXrefMatches(matched, text) { } const node = idlStringToHtml(ref); - // If it's inside a dfn, it should just be coded, not linked. + // If it's inside a dfn or a `a`, it should just be coded, not linked. // This is because dfn elements are treated as links by ReSpec via role=link. - const renderAsCode = !!text.parentElement.closest("dfn"); + const renderAsCode = !!text.parentElement.closest("dfn") || !!text.parentElement.closest("a"); return renderAsCode ? inlineCodeMatches(`\`${node.textContent}\``) : node; } diff --git a/tests/spec/core/inlines-spec.js b/tests/spec/core/inlines-spec.js index 7e26c43818..a08815174c 100644 --- a/tests/spec/core/inlines-spec.js +++ b/tests/spec/core/inlines-spec.js @@ -629,7 +629,7 @@ describe("Core - Inlines", () => { expect(primitiveData.lt).toBe("unsigned short"); }); - it("doesn't link processed inline WebIDL if inside a definition", async () => { + it("doesn't link processed inline WebIDL if inside a definition or a link", async () => { const body = `
@@ -639,14 +639,18 @@ describe("Core - Inlines", () => { {{ ReferrerPolicy/"no-referrer" }} 123 + A link containing an IDL reference {{Window}}
`; const doc = await makeRSDoc(makeStandardOps(null, body)); const dfn = doc.getElementById("dfn"); expect(dfn.querySelector("a")).toBeNull(); + const link = doc.getElementById("link"); + expect(link.querySelector("a")).toBeNull(); const codeElements = dfn.querySelectorAll("code"); expect(codeElements).toHaveSize(3); + expect(link.querySelectorAll("code")).toHaveSize(1); const [eventListen, event, noRef] = codeElements; expect(eventListen.textContent).toBe("addEventListener(type, callback)");