Skip to content

Commit 3e4c8cd

Browse files
authored
Merge branch 'main' into dependabot/github_actions/actions/setup-node-5
2 parents b245a90 + 91fd7d5 commit 3e4c8cd

File tree

6 files changed

+97
-10
lines changed

6 files changed

+97
-10
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
steps:
4040
- name: Checkout repository
41-
uses: actions/checkout@v4
41+
uses: actions/checkout@v5
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL

.github/workflows/pr.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
name: Check linting issues
2626
runs-on: ubuntu-latest
2727
steps:
28-
- uses: actions/checkout@v4
28+
- uses: actions/checkout@v5
2929
- name: Ensure builds/ has not changed
3030
run: |
3131
curl -sL https://api.github.com/repos/speced/respec/pulls/${{ github.event.pull_request.number }}/files -o /tmp/pr_files.json
@@ -42,7 +42,7 @@ jobs:
4242
runs-on: ubuntu-latest
4343
needs: lint
4444
steps:
45-
- uses: actions/checkout@v4
45+
- uses: actions/checkout@v5
4646
- uses: pnpm/action-setup@v4
4747
- uses: actions/setup-node@v5
4848
with: { node-version-file: '.nvmrc', cache: pnpm }
@@ -59,7 +59,7 @@ jobs:
5959
runs-on: ubuntu-latest
6060
needs: lint
6161
steps:
62-
- uses: actions/checkout@v4
62+
- uses: actions/checkout@v5
6363
- uses: pnpm/action-setup@v4
6464
- uses: actions/setup-node@v5
6565
with: { node-version-file: '.nvmrc', cache: pnpm }
@@ -77,7 +77,7 @@ jobs:
7777
runs-on: ubuntu-latest
7878
needs: lint
7979
steps:
80-
- uses: actions/checkout@v4
80+
- uses: actions/checkout@v5
8181
- uses: pnpm/action-setup@v4
8282
- uses: actions/setup-node@v5
8383
with: { node-version-file: '.nvmrc', cache: pnpm }

.github/workflows/push.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
name: Headless Tests
2828
runs-on: ubuntu-latest
2929
steps:
30-
- uses: actions/checkout@v4
30+
- uses: actions/checkout@v5
3131
- uses: pnpm/action-setup@v4
3232
- uses: actions/setup-node@v5
3333
with: { node-version-file: '.nvmrc', cache: pnpm }
@@ -52,7 +52,7 @@ jobs:
5252
name: Karma Unit Tests (Chrome)
5353
runs-on: ubuntu-latest
5454
steps:
55-
- uses: actions/checkout@v4
55+
- uses: actions/checkout@v5
5656
- uses: pnpm/action-setup@v4
5757
- uses: actions/setup-node@v5
5858
with: { node-version-file: '.nvmrc', cache: pnpm }

.github/workflows/regressions.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: Build W3C profile
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v4
14+
- uses: actions/checkout@v5
1515
- uses: pnpm/action-setup@v4
1616
- uses: actions/setup-node@v5
1717
with: { node-version-file: '.nvmrc', cache: pnpm }
@@ -41,7 +41,7 @@ jobs:
4141
- https://w3c.github.io/geolocation-api/
4242
fail-fast: false
4343
steps:
44-
- uses: actions/checkout@v4
44+
- uses: actions/checkout@v5
4545
- uses: pnpm/action-setup@v4
4646
- uses: actions/setup-node@v5
4747
with: { node-version-file: '.nvmrc', cache: pnpm }

src/core/dfn-index.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
import { addId, getIntlData, norm, xmlEscape } from "./utils.js";
9+
import { biblio } from "./biblio.js";
910
import css from "../styles/dfn-index.css.js";
1011
import { getTermFromElement } from "./xref.js";
1112
import { html } from "./import-maps.js";
@@ -21,48 +22,56 @@ const localizationStrings = {
2122
headingExternal: "Terms defined by reference",
2223
headingLocal: "Terms defined by this specification",
2324
dfnOf: "definition of",
25+
definesFollowing: "defines the following:",
2426
},
2527
cs: {
2628
heading: "Glosář",
2729
headingExternal: "Termíny definované odkazem",
2830
headingLocal: "Termíny definované touto specifikací",
2931
dfnOf: "definice",
32+
definesFollowing: "definuje následující:",
3033
},
3134
de: {
3235
heading: "Index",
3336
headingExternal: "Begriffe, die durch Verweis definiert sind",
3437
headingLocal: "Begriffe, die in dieser Spezifikation definiert sind",
3538
dfnOf: "Definition von",
39+
definesFollowing: "definiert Folgendes:",
3640
},
3741
es: {
3842
heading: "Índice",
3943
headingExternal: "Términos definidos por referencia",
4044
headingLocal: "Términos definidos por esta especificación",
4145
dfnOf: "definición de",
46+
definesFollowing: "define lo siguiente:",
4247
},
4348
ja: {
4449
heading: "索引",
4550
headingExternal: "参照によって定義された用語",
4651
headingLocal: "この仕様で定義された用語",
4752
dfnOf: "の定義",
53+
definesFollowing: "以下を定義します:",
4854
},
4955
ko: {
5056
heading: "색인",
5157
headingExternal: "참조로 정의된 용어",
5258
headingLocal: "이 명세서에서 정의된 용어",
5359
dfnOf: "정의",
60+
definesFollowing: "다음을 정의합니다:",
5461
},
5562
nl: {
5663
heading: "Index",
5764
headingExternal: "Termen gedefinieerd door verwijzing",
5865
headingLocal: "Termen gedefinieerd door deze specificatie",
5966
dfnOf: "definitie van",
67+
definesFollowing: "definieert het volgende:",
6068
},
6169
zh: {
6270
heading: "索引",
6371
headingExternal: "通过引用定义的术语",
6472
headingLocal: "由本规范定义的术语",
6573
dfnOf: "的定义",
74+
definesFollowing: "定义以下内容:",
6675
},
6776
};
6877
const l10n = getIntlData(localizationStrings);
@@ -283,10 +292,21 @@ function createExternalTermIndex() {
283292
const dataSortedBySpec = [...data.entries()].sort(([specA], [specB]) =>
284293
specA.localeCompare(specB)
285294
);
295+
const indexSection = document.querySelector("section#index");
296+
const useFullTitle = !!indexSection?.classList.contains(
297+
"prefer-full-spec-title"
298+
);
286299
return html`<ul class="index">
287300
${dataSortedBySpec.map(([spec, entries]) => {
301+
let citationElement;
302+
if (useFullTitle && biblio[spec]?.title) {
303+
citationElement = renderInlineCitation(spec, biblio[spec].title);
304+
} else {
305+
citationElement = renderInlineCitation(spec);
306+
}
307+
288308
return html`<li data-spec="${spec}">
289-
${renderInlineCitation(spec)} defines the following:
309+
${citationElement} ${l10n.definesFollowing}
290310
<ul>
291311
${entries
292312
.sort((a, b) => a.term.localeCompare(b.term))

tests/spec/core/dfn-index-spec.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,28 @@ describe("Core — dfn-index", () => {
154154
expect(secNum.textContent).toBe("§1.");
155155
expect(item.textContent.endsWith("§1.")).toBeTrue();
156156
});
157+
158+
it("prefer-full-spec-title class doesn't affect local terms", async () => {
159+
const body = `<section id="content">
160+
<h2>Whatever</h2>
161+
<p class="test"><dfn>hello</dfn> <dfn>bar</dfn></p>
162+
</section>
163+
<section id="index" class="prefer-full-spec-title"></section>`;
164+
const ops = makeStandardOps(null, body);
165+
const doc = await makeRSDoc(ops);
166+
const localIndex = doc.getElementById("index-defined-here");
167+
168+
// Local terms should not be affected by prefer-full-spec-title class
169+
// They should still show just the term names without any spec citations
170+
const terms = [...localIndex.querySelectorAll("ul.index > li")].map(
171+
term => term.textContent.trim().split(/\s/)[0]
172+
);
173+
expect(terms).toEqual(["bar", "hello"]);
174+
175+
// Verify no citation elements are present in local terms
176+
expect(localIndex.querySelectorAll("cite")).toHaveSize(0);
177+
expect(localIndex.querySelectorAll(".bibref")).toHaveSize(0);
178+
});
157179
});
158180

159181
describe("External Terms Index", () => {
@@ -281,6 +303,51 @@ describe("Core — dfn-index", () => {
281303
expect(termsInDom).toHaveSize(4);
282304
});
283305

306+
it("uses localized text for 'defines the following'", async () => {
307+
// Test with default language (English)
308+
const bySpecs = index.querySelectorAll("ul.index > li");
309+
expect(bySpecs[0].textContent.trim()).toMatch(
310+
/\[DOM\] defines the following:/
311+
);
312+
313+
// Test with a different language
314+
const body = ` <section id="content">
315+
<p>{{ Event }}</p>
316+
</section>
317+
<section id="index"></section>`;
318+
const ops = makeStandardOps({ xref: "web-platform" }, body);
319+
ops.htmlAttrs = { lang: "es" };
320+
const doc = await makeRSDoc(ops);
321+
const spanishIndex = doc.getElementById("index-defined-elsewhere");
322+
const spanishBySpecs = spanishIndex.querySelectorAll("ul.index > li");
323+
if (spanishBySpecs.length > 0) {
324+
expect(spanishBySpecs[0].textContent.trim()).toMatch(
325+
/\[DOM\] define lo siguiente:/
326+
);
327+
}
328+
});
329+
330+
it("uses full spec title when prefer-full-spec-title class is present", async () => {
331+
const body = ` <section id="content">
332+
<p>{{ Event }}</p>
333+
</section>
334+
<section id="index" class="prefer-full-spec-title"></section>`;
335+
const ops = makeStandardOps({ xref: "web-platform" }, body);
336+
const doc = await makeRSDoc(ops);
337+
const fullTitleIndex = doc.getElementById("index-defined-elsewhere");
338+
const bySpecs = fullTitleIndex.querySelectorAll("ul.index > li");
339+
340+
if (bySpecs.length > 0) {
341+
// Should use full title instead of just [DOM]
342+
expect(bySpecs[0].textContent.trim()).toMatch(
343+
/DOM Standard defines the following:/
344+
);
345+
expect(bySpecs[0].textContent.trim()).not.toMatch(
346+
/^\[DOM\] defines the following:/
347+
);
348+
}
349+
});
350+
284351
it("lists terms in a spec in sorted order", () => {
285352
const termsInDom = index.querySelectorAll("[data-spec='DOM'] li");
286353
expect(termsInDom).toHaveSize(4);

0 commit comments

Comments
 (0)