Skip to content

Commit

Permalink
Remove check for old integration (#429)
Browse files Browse the repository at this point in the history
We are not injecting `readthedocs-doc-embed.js` anymore and it's being
removed by the CF worker anyways. This is dead code now.
  • Loading branch information
humitos authored Nov 13, 2024
1 parent f2dcdaf commit 3039290
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 31 deletions.
6 changes: 3 additions & 3 deletions dist/readthedocs-addons.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/readthedocs-addons.js.map

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,12 @@ import * as linkpreviews from "./linkpreviews";
import * as filetreediff from "./filetreediff";
import {
domReady,
isReadTheDocsEmbedPresent,
IS_PRODUCTION,
setupLogging,
getMetadataValue,
} from "./utils";

export function setup() {
if (isReadTheDocsEmbedPresent()) {
console.debug("Read the Docs Embed is present. Skipping...");
// TODO: return ``Promise.reject()`` or similar here to avoid hybrid async/sync functions.
return false;
}

const addons = [
flyout.FlyoutAddon,
notification.NotificationAddon,
Expand Down
10 changes: 0 additions & 10 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ export const IS_TESTING =
export const IS_PRODUCTION =
typeof WEBPACK_IS_PRODUCTION === "undefined" ? false : WEBPACK_IS_PRODUCTION;

export function isReadTheDocsEmbedPresent() {
const urls = [
"/_/static/javascript/readthedocs-doc-embed.js",
"https://assets.readthedocs.org/static/javascript/readthedocs-doc-embed.js",
];
for (const url of urls) {
return document.querySelectorAll(`script[src="${url}"]`).length > 0;
}
}

export const domReady = new Promise((resolve) => {
if (
document.readyState === "interactive" ||
Expand Down
10 changes: 0 additions & 10 deletions tests/index.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,6 @@
new URLSearchParams(params).toString();
expect(server.requests[0].url).to.be.equal(url);
});

it("skip everything because Read the Docs Embed is present", async () => {
const script = document.createElement("script");
script.src = "/_/static/javascript/readthedocs-doc-embed.js";
document.body.append(script);

// Our .setup() returns "false" when old embed js is present
const result = readthedocs.setup();
expect(result).to.be.false;
});
});
});
</script>
Expand Down

0 comments on commit 3039290

Please sign in to comment.