Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
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
13 changes: 6 additions & 7 deletions builds/respec-aom.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions builds/respec-dini.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions builds/respec-geonovum.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions builds/respec-w3c.js
Original file line number Diff line number Diff line change
Expand Up @@ -13497,6 +13497,7 @@ body:has(input[name=color-scheme][value=dark]:checked){color-scheme:dark}`;
name: tc,
run: function () {
for (const e of document.querySelectorAll("dfn")) {
if (e.closest("del")) continue;
const t = Hr(e);
if ((ec(e, t), e.dataset.cite && /\b#\b/.test(e.dataset.cite)))
continue;
Expand Down Expand Up @@ -17772,13 +17773,11 @@ var[data-type]:hover::after,var[data-type]:hover::before{opacity:1}`;
});
const r = ([e, t]) =>
[{ title: e, id: t[0], text: e }].concat(
t
.slice(1)
.map((e, t) => ({
title: `Reference ${t + 2}`,
text: `(${t + 2})`,
id: e,
}))
t.slice(1).map((e, t) => ({
title: `Reference ${t + 2}`,
text: `(${t + 2})`,
id: e,
}))
),
s = e => or`<li>
${r(e).map(
Expand Down
1 change: 1 addition & 0 deletions src/core/dfn.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const knownTypes = [...knownTypesMap.keys()];

export function run() {
for (const dfn of document.querySelectorAll("dfn")) {
if (dfn.closest("del")) continue;
const titles = getDfnTitles(dfn);
registerDefinition(dfn, titles);

Expand Down
1 change: 1 addition & 0 deletions src/core/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export async function run(conf) {
showWarning(msg, name);
}
}
const newIssuesURL = new URL("./new/choose", issueBase).href;
Comment thread
github-code-quality[bot] marked this conversation as resolved.
Fixed
if (!conf.excludeGithubLinks) {
const otherLink = {
key: l10n.participate,
Expand Down
2 changes: 1 addition & 1 deletion src/core/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function highlightElement(elem) {
const languages = getLanguageHint(htmlElem.classList);
let response;
try {
response = await sendHighlightRequest(htmlElem.innerText, languages);
response = await sendHighlightRequest(htmlElem.textContent, languages);
} catch (err) {
console.error(err);
return;
Expand Down
13 changes: 12 additions & 1 deletion src/w3c/templates/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export default (conf, options) => {
<dd>
${conf.latestVersion
? html`<a href="${conf.latestVersion}"
>${conf.latestVersion}</a
>${safeDecodeURI(conf.latestVersion)}</a
>`
Comment thread
marcoscaceres marked this conversation as resolved.
Comment thread
marcoscaceres marked this conversation as resolved.
: "none"}
</dd>`
Expand Down Expand Up @@ -460,6 +460,17 @@ function renderSpecTitle(conf) {
: ""}`;
}

/**
* @param {string} iri
*/
function safeDecodeURI(iri) {
try {
return decodeURI(iri);
} catch {
return iri;
}
Comment thread
marcoscaceres marked this conversation as resolved.
}

/**
* @param { LicenseInfo } licenseInfo license information
*/
Expand Down
24 changes: 24 additions & 0 deletions tests/spec/core/dfn-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,30 @@ describe("Core — Definitions", () => {
expect(dfn6.dataset.export).toBeUndefined();
});

it("skips <dfn> elements inside <del> (deleted content)", async () => {
const body = `
<section id='dfns'>
<del><dfn>shared term</dfn></del>
<dfn id="kept">shared term</dfn>
<a>shared term</a>
</section>`;
const ops = makeStandardOps(null, body);
const doc = await makeRSDoc(ops);
const active = doc.querySelector("section#dfns > dfn");
const deleted = doc.querySelector("del dfn");
const link = doc.querySelector("#dfns a");
// Active definitions are processed and linked normally.
expect(active).toBeTruthy();
expect(active.id).toBe("kept");
expect(active.dataset.dfnType).toBe("dfn");
// Deleted definitions remain in the DOM.
expect(deleted).toBeTruthy();
expect(deleted.closest("del")).toBeTruthy();
// Deleted definitions should not participate in duplicate checks or linking.
expect(findDfnErrors(doc)).toEqual([]);
expect(link.getAttribute("href")).toBe("#kept");
});

it("makes dfn tab enabled whose aria-role is a link", async () => {
const body = `
<section id='dfns'>
Expand Down
13 changes: 10 additions & 3 deletions tests/spec/core/github-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ describe("Core - Github", () => {
);
expect(conf.github.repoURL).toBe("https://github.com/w3c/core-aam/");
});
it("sets newIssuesURL to /new/choose on the normalized github object", async () => {
const doc = await makeRSDoc(stringOpt);
const { respecConfig: conf } = doc.defaultView;
expect(conf.github.newIssuesURL).toBe(
"https://github.com/speced/respec/issues/new/choose"
);
});
});
describe("the definition list items (localized)", () => {
const l10n = {
Expand Down Expand Up @@ -214,16 +221,16 @@ describe("Core - Github", () => {
elem => elem.textContent.trim() === "Dien een melding in"
);
expect(fileABug).toBeTruthy();
expect(fileABug.querySelector("a").href).toBe(
"https://github.com/w3c/core-aam/issues/new/choose"
);
const allIssues = Array.from(doc.querySelectorAll("dd")).find(
elem => elem.textContent.trim() === "All issues"
);
expect(allIssues).toBeTruthy();
expect(allIssues.querySelector("a").href).toBe(
"https://github.com/w3c/core-aam/issues/"
);
expect(fileABug.querySelector("a").href).toBe(
"https://github.com/w3c/core-aam/issues/new/choose"
);
});
});
});
17 changes: 17 additions & 0 deletions tests/spec/core/highlight-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,21 @@ describe("Core — Highlight", () => {
expect(lastCode.textContent).toContain("Header: Test5");
expect(lastCode.classList).toContain("http");
});

it("highlights <pre> inside a closed <details> element", async () => {
const body = `
<section>
<details id="closed-details">
<summary>Toggle</summary>
<pre class="js" id="details-pre">function bar() { return 1; }</pre>
</details>
Comment thread
marcoscaceres marked this conversation as resolved.
</section>
`;
const ops = makeStandardOps(null, body);
const doc = await makeRSDoc(ops);
const details = doc.getElementById("closed-details");
expect(details.open).toBeFalse();
const pre = doc.getElementById("details-pre");
expect(pre.querySelector("span[class*=hljs-]")).toBeTruthy();
});
});
37 changes: 37 additions & 0 deletions tests/spec/w3c/headers-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1617,6 +1617,43 @@ describe("W3C — Headers", () => {
expect(latestVersionDd.textContent.trim()).toBe("none");
});
}

it("displays decoded IRI as link text while keeping encoded URL in href", async () => {
const encodedLatestVersion = "https://www.w3.org/TR/f%C3%B6%C3%B6-spec/";
const ops = makeStandardOps({
specStatus: "WD",
group: "webapps",
latestVersion: encodedLatestVersion,
});
const doc = await makeRSDoc(ops);
const terms = [...doc.querySelectorAll(".head dt")];
const latestVersionDt = terms.find(
el => el.textContent.trim() === "Latest published version:"
);
expect(latestVersionDt).toBeTruthy();
const link = latestVersionDt.nextElementSibling.querySelector("a");
expect(link.getAttribute("href")).toBe(encodedLatestVersion);
expect(link.textContent.trim()).toBe("https://www.w3.org/TR/föö-spec/");
});

it("falls back to the original latestVersion when URI decoding fails", async () => {
const malformedLatestVersion =
"https://www.w3.org/TR/f%C3%B6%C3%B6-spec/%";
const ops = makeStandardOps({
specStatus: "WD",
group: "webapps",
latestVersion: malformedLatestVersion,
});
const doc = await makeRSDoc(ops);
const terms = [...doc.querySelectorAll(".head dt")];
const latestVersionDt = terms.find(
el => el.textContent.trim() === "Latest published version:"
);
expect(latestVersionDt).toBeTruthy();
const link = latestVersionDt.nextElementSibling.querySelector("a");
expect(link.getAttribute("href")).toBe(malformedLatestVersion);
expect(link.textContent.trim()).toBe(malformedLatestVersion);
});
});

describe("prevED", () => {
Expand Down
Loading