Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/core/dfn-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: "参照によって定義された用語",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"));
}
16 changes: 16 additions & 0 deletions tests/spec/core/dfn-index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `<section data-cite="DOM">
<h2>TEST</h2>
<p>{{ Event }} {{ Event/type }}</p>
<p><a data-cite="DOM#interface-event" data-noindex>Event (noindex)</a></p>
</section>
<section id="index"></section>`;
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()
);
Comment thread
marcoscaceres marked this conversation as resolved.
expect(terms).not.toContain("Event (noindex)");
});
});
});
Loading