1
- import MutationObserver from '@sheerun/mutationobserver-shim '
1
+ import { newMutationObserver , getDocument } from './helpers '
2
2
3
3
function waitForDomChange ( {
4
4
container = getDocument ( ) ,
@@ -12,13 +12,7 @@ function waitForDomChange({
12
12
} = { } ) {
13
13
return new Promise ( ( resolve , reject ) => {
14
14
const timer = setTimeout ( onTimeout , timeout )
15
- /* istanbul ignore next */
16
- const MutationObserverConstructor =
17
- typeof window !== 'undefined' &&
18
- typeof window . MutationObserver !== 'undefined'
19
- ? window . MutationObserver
20
- : MutationObserver
21
- const observer = new MutationObserverConstructor ( onMutation )
15
+ const observer = newMutationObserver ( onMutation )
22
16
observer . observe ( container , mutationObserverOptions )
23
17
24
18
function onDone ( error , result ) {
@@ -39,12 +33,4 @@ function waitForDomChange({
39
33
} )
40
34
}
41
35
42
- function getDocument ( ) {
43
- /* istanbul ignore if */
44
- if ( typeof window === 'undefined' ) {
45
- throw new Error ( 'Could not find default container' )
46
- }
47
- return window . document
48
- }
49
-
50
36
export { waitForDomChange }
0 commit comments