aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/observe-dom.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/observe-dom.ts')
-rw-r--r--src/utils/observe-dom.ts8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/utils/observe-dom.ts b/src/utils/observe-dom.ts
index 30a07b4..8ea1a98 100644
--- a/src/utils/observe-dom.ts
+++ b/src/utils/observe-dom.ts
@@ -1,8 +1,12 @@
-export const observeDOM = (callback: () => boolean) => {
+export const observeDOM = (callback: () => boolean, element: HTMLElement = document as unknown as HTMLElement) => {
const observer = new MutationObserver(() => {
if (callback()) {
observer.disconnect();
}
});
- observer.observe(document, {childList: true, subtree: true});
+
+ observer.observe(element, {
+ childList: true,
+ subtree: true
+ });
};