From c33294bd1d895405fcb7d6a2978f8db09da61c19 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Mon, 4 May 2026 10:45:41 +1000 Subject: [PATCH 1/2] feat(core/dfn-index): support data-noindex to exclude from external terms index Closes #4895 --- src/core/dfn-index.js | 14 ++++++++++++++ tests/spec/core/dfn-index-spec.js | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) 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..5b84a57619 100644 --- a/tests/spec/core/dfn-index-spec.js +++ b/tests/spec/core/dfn-index-spec.js @@ -502,5 +502,21 @@ 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"); + const terms = [...externalIndex.querySelectorAll(".index-term")].map(el => + el.textContent.trim() + ); + expect(terms).not.toContain("Event (noindex)"); + }); }); }); From 904170d419eece11225787fa6716fd1f442f8dca Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Mon, 4 May 2026 21:40:39 +1000 Subject: [PATCH 2/2] test(core/dfn-index): assert external index exists in data-noindex test Address Copilot feedback: the test now asserts that the external index section exists and contains the expected 'Event interface' term, so the absence assertion for the excluded term cannot vacuously pass when the index is empty. --- tests/spec/core/dfn-index-spec.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/spec/core/dfn-index-spec.js b/tests/spec/core/dfn-index-spec.js index 5b84a57619..1739801be6 100644 --- a/tests/spec/core/dfn-index-spec.js +++ b/tests/spec/core/dfn-index-spec.js @@ -513,9 +513,12 @@ describe("Core — dfn-index", () => { 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)"); }); });