diff --git a/src/core/dfn-index.js b/src/core/dfn-index.js index 3bfa9772e1..83f831cfd6 100644 --- a/src/core/dfn-index.js +++ b/src/core/dfn-index.js @@ -45,6 +45,13 @@ const localizationStrings = { dfnOf: "definición de", definesFollowing: "define lo siguiente:", }, + fr: { + heading: "Index", + headingExternal: "Termes définis par référence", + headingLocal: "Termes définis par cette spécification", + dfnOf: "définition de", + definesFollowing: "définit les termes suivants :", + }, ja: { heading: "索引", headingExternal: "参照によって定義された用語", @@ -344,6 +351,9 @@ function collectExternalTerms() { if (!elem.dataset.cite) { continue; } + if ("noindex" in elem.dataset) { + continue; + } const { cite, citeFrag, xrefType, linkType } = elem.dataset; if (!(xrefType || linkType || cite.includes("#") || citeFrag)) { // Not a reference to a definition @@ -459,4 +469,8 @@ function cleanup(doc) { doc .querySelectorAll("#index-defined-here li[data-id]") .forEach(el => el.removeAttribute("data-id")); + + doc + .querySelectorAll("a[data-noindex]") + .forEach(el => el.removeAttribute("data-noindex")); } diff --git a/tests/spec/core/dfn-index-spec.js b/tests/spec/core/dfn-index-spec.js index c562565c83..1739801be6 100644 --- a/tests/spec/core/dfn-index-spec.js +++ b/tests/spec/core/dfn-index-spec.js @@ -502,5 +502,24 @@ describe("Core — dfn-index", () => { expect(parsing1.id).toBe("index-term-parsing"); expect(parsing2.id).toBe("index-term-parsing-0"); }); + + it("excludes terms with data-noindex from the external index", async () => { + const body = `
+

TEST

+

{{ Event }} {{ Event/type }}

+

Event (noindex)

+
+
`; + const ops = makeStandardOps({ xref: "web-platform" }, body); + const doc = await makeRSDoc(ops); + const externalIndex = doc.getElementById("index-defined-elsewhere"); + expect(externalIndex).toBeTruthy(); + const terms = [...externalIndex.querySelectorAll(".index-term")].map(el => + el.textContent.trim() + ); + expect(terms.length).toBeGreaterThan(0); + expect(terms).toContain("Event interface"); + expect(terms).not.toContain("Event (noindex)"); + }); }); });