Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
fix(core): revert making "task source" a type (speced#3744)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres authored Aug 13, 2021
1 parent 2bed309 commit f79b778
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 84 deletions.
13 changes: 0 additions & 13 deletions src/core/dfn.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,6 @@ function computeType(dfn, linkingText) {
case slotRegex.test(linkingText):
type = processAsInternalSlot(linkingText, dfn);
break;

// A definition that ends with "task source" is a "task-source"...
case /\b task source$/i.test(linkingText):
type = "task-source";
processAsTaskSource(dfn);
break;
}

// Derive closest type
Expand All @@ -116,13 +110,6 @@ function computeType(dfn, linkingText) {
// But other modules may end up adding a type (e.g., the WebIDL module)
}

function processAsTaskSource(dfn) {
// Task sources are exported by default.
if (!dfn.matches(".no-export, [data-noexport]")) {
dfn.dataset.export = "";
}
}

// Deal with export/no export
function computeExport(dfn) {
switch (true) {
Expand Down
8 changes: 1 addition & 7 deletions src/core/inlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,8 @@ function inlineAnchorMatches(matched) {
: [null, content];
const processedContent = processInlineContent(text);
const forContext = isFor ? norm(isFor) : null;
let type = "dfn";
switch (true) {
case /task\s+source$/i.test(matched):
type = "task-source";
break;
}
return html`<a
data-link-type="${type}"
data-link-type="dfn"
data-link-for="${forContext}"
data-xref-for="${forContext}"
data-lt="${linkingText}"
Expand Down
64 changes: 0 additions & 64 deletions tests/spec/core/dfn-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,70 +232,6 @@ describe("Core — Definitions", () => {
}
});

it("automatically identifies task sources and exports them by default", async () => {
const body = `
<section>
<h2>Task sources</h2>
<p>
<!-- valid for export -->
<dfn id="task-1">I'm a
task
source
</dfn>
<!-- Won't match, because no name -->
<dfn id="task-2">
task source
</dfn>
<!-- explicit no export -->
<dfn id="task-3" data-noexport="">
secret
task source
</dfn>
<dfn class="no-export" id="task-4" data-dfn-type="custom-type">
Custom task source
</dfn>
</p>
<p id="links">
<a>I'm a task source</a>
[=I'm a
Task
Source=]
</p>
</section>
`;
const ops = makeStandardOps(null, body);
const doc = await makeRSDoc(ops);

const dfn = doc.getElementById("task-1");
expect(dfn.dataset.dfnFor).toBeUndefined();
expect(dfn.dataset.export).toBe("");
expect(dfn.dataset.dfnType).toBe("task-source");

const dfn2 = doc.getElementById("task-2");
expect(dfn2.dataset.dfnFor).toBeUndefined();
expect(dfn2.dataset.export).toBeUndefined();
expect(dfn2.dataset.dfnType).toBe("dfn");

const dfn3 = doc.getElementById("task-3");
expect(dfn3.dataset.dfnFor).toBeUndefined();
expect(dfn3.dataset.export).toBeUndefined();
expect(dfn3.dataset.dfnType).toBe("task-source");
expect(dfn3.dataset.noexport).toBe("");

const dfn4 = doc.getElementById("task-4");
expect(dfn4.dataset.dfnFor).toBeUndefined();
expect(dfn4.dataset.export).toBeUndefined();
expect(dfn4.dataset.dfnType).toBe("custom-type");
expect(dfn4.dataset.noexport).toBe("");

const [link1, link2] = doc.querySelectorAll("#links a");
expect(link1.hash).toBe(`#${dfn.id}`);
expect(link2.hash).toBe(`#${dfn.id}`);
expect(link2.dataset.linkType).toBe(`task-source`);
});

it("supports permission type", async () => {
const ops = {
config: makeBasicConfig(),
Expand Down

0 comments on commit f79b778

Please sign in to comment.