Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/core/link-to-dfn.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ function updateReferences(conf) {
// turning "HTML" into "__SPEC__HTML".
// https://regex101.com/r/rsZyIJ/5
const regex = shortName
? new RegExp(String.raw`^([?!])?${regExpEscape(shortName)}\b([^-])`, "i")
? new RegExp(String.raw`^([?!])?${regExpEscape(shortName)}\b([^-]|$)`, "i")
: null;

/** @type {NodeListOf<HTMLElement>} */
Expand Down
20 changes: 20 additions & 0 deletions tests/spec/core/data-cite-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,26 @@ describe("Core — data-cite attribute", () => {
expect(anchor2.textContent).toBe("webxr-gamepads-module-1");
});

it("treats a data-cite of just the shortName as self citing", async () => {
const body = `
<section>
<h2>test</h2>
<p id="test">
[[[gamepad]]], <a data-cite="!gamepad">this spec</a>
</p>
</section>
`;
const ops = makeStandardOps({ shortName: "gamepad" }, body);
const doc = await makeRSDoc(ops);
const [anchor1, anchor2] = doc.querySelectorAll("#test a");
const location = new URL(doc.location.href);
location.hash = "";

expect(anchor1.href).toBe(location.href);
expect(anchor2.href).toBe(location.href);
expect(doc.getElementById("bib-gamepad")).toBeNull();
});

it("links data-cite attributes as normative/informative reference when parent is citing", async () => {
const body = `
<section class="informative" data-cite="FETCH">
Expand Down