Skip to content

Commit 12c27ca

Browse files
fix(core/dfn): prevent adding data-local-lt to data-lt (#5014)
1 parent 9885d13 commit 12c27ca

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/core/dfn.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,12 @@ export function run() {
7171
computeType(dfn, linkingText);
7272
computeExport(dfn);
7373

74-
// Only add `lt`s that are different from the text content
75-
if (titles.length === 1 && linkingText === norm(dfn.textContent)) {
76-
continue;
74+
// Only add `lt`s that are different from the text content and local-lts
75+
const localLt = (dfn.dataset.localLt || "").split("|").map(norm);
76+
const lt = titles.filter(t => !localLt.includes(t));
77+
if (lt.length > 1 || linkingText !== norm(dfn.textContent)) {
78+
dfn.dataset.lt = lt.join("|");
7779
}
78-
dfn.dataset.lt = titles.join("|");
7980
}
8081
}
8182

tests/spec/core/dfn-spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ describe("Core — Definitions", () => {
221221

222222
const dfnOnlyLocalLt = doc.querySelector("#only-local-lt dfn");
223223
expect(dfnOnlyLocalLt.id).toBe("dfn-install");
224+
expect(dfnOnlyLocalLt.dataset.lt).toBe(undefined);
224225
for (const el of [...doc.querySelectorAll("#only-local-lt a")]) {
225226
expect(el.hash).toBe("#dfn-install");
226227
}

0 commit comments

Comments
 (0)