Skip to content

Commit

Permalink
feat(rx): allow passing ElementRef of Element to create-mutation-obse…
Browse files Browse the repository at this point in the history
…rver
  • Loading branch information
michaelbe812 committed Jan 19, 2023
1 parent df78519 commit 903807a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libs/rx/platform/src/lib/create-mutation-observer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {debounceTime, Observable, ReplaySubject, SchedulerLike, share} from 'rxjs';
import {ElementRef} from '@angular/core';
import {isElementRef} from "./utils/is-element-ref";

const DEFAULT_THROTTLE_TIME = 125;

Expand All @@ -8,7 +9,7 @@ export function supportsMutationObserver() {
}

export function createMutationObserver(
observeElement: ElementRef,
observeElement: ElementRef | Element,
options?: MutationObserverInit,
cfg?: {
throttleMs?: number;
Expand All @@ -23,7 +24,7 @@ export function createMutationObserver(
subscriber.next(entries);
});

mutationObserver.observe(observeElement.nativeElement, options ?? {});
mutationObserver.observe(isElementRef(observeElement) ? observeElement.nativeElement : observeElement, options ?? {});

return () => mutationObserver.disconnect();
});
Expand Down

0 comments on commit 903807a

Please sign in to comment.