summaryrefslogtreecommitdiff
path: root/source/libs
diff options
context:
space:
mode:
Diffstat (limited to 'source/libs')
-rw-r--r--source/libs/dom-utils.ts16
-rw-r--r--source/libs/features.tsx4
2 files changed, 2 insertions, 18 deletions
diff --git a/source/libs/dom-utils.ts b/source/libs/dom-utils.ts
index 9b7a8941..eedd8921 100644
--- a/source/libs/dom-utils.ts
+++ b/source/libs/dom-utils.ts
@@ -1,20 +1,4 @@
import select from 'select-dom';
-import domLoaded from 'dom-loaded';
-import elementReady from 'element-ready';
-
-/*
- * Automatically stops checking for an element to appear once the DOM is ready.
- */
-export const safeElementReady = <T extends Element>(selector: string): Promise<T | null> => {
- const waiting = elementReady<T>(selector);
-
- // Don't check ad-infinitum
- // eslint-disable-next-line promise/prefer-await-to-then
- domLoaded.then(() => requestAnimationFrame(() => waiting.cancel()));
-
- // If cancelled, return null like a regular select() would
- return waiting.catch(() => null);
-};
/**
* Append to an element, but before a element that might not exist.
diff --git a/source/libs/features.tsx b/source/libs/features.tsx
index a8da200a..be1a159a 100644
--- a/source/libs/features.tsx
+++ b/source/libs/features.tsx
@@ -2,10 +2,10 @@ import React from 'dom-chef';
import select from 'select-dom';
import onDomReady from 'dom-loaded';
import OptionsSync from 'webext-options-sync';
+import elementReady from 'element-ready';
import onNewComments from './on-new-comments';
import onFileListUpdate from './on-file-list-update';
import * as pageDetect from './page-detect';
-import {safeElementReady} from './dom-utils';
type BooleanFunction = () => boolean;
type VoidFunction = () => void;
@@ -79,7 +79,7 @@ onAjaxedPages(async () => {
// Rule assumes we don't want to leave it pending:
// eslint-disable-next-line no-async-promise-executor
const globalReady: Promise<GlobalOptions> = new Promise(async resolve => {
- await safeElementReady('body');
+ await elementReady('body');
if (pageDetect.is500()) {
return;