Skip to content

Commit 7730d25

Browse files
dadamssgKent C. Dodds
authored and
Kent C. Dodds
committed
fix: Reference Node and MutationObserver off of the window object rather than globally (#77)
You have to handle shims yourself if not using jest without this
1 parent 6e9d7c5 commit 7730d25

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/get-node-text.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
function getNodeText(node) {
22
return Array.from(node.childNodes)
33
.filter(
4-
child => child.nodeType === Node.TEXT_NODE && Boolean(child.textContent),
4+
child =>
5+
child.nodeType === window.Node.TEXT_NODE && Boolean(child.textContent),
56
)
67
.map(c => c.textContent)
78
.join(' ')

src/wait-for-element.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function waitForElement(
4646
onDone(lastError || new Error('Timed out in waitForElement.'), null)
4747
}
4848
timer = setTimeout(onTimeout, timeout)
49-
observer = new MutationObserver(onMutation)
49+
observer = new window.MutationObserver(onMutation)
5050
observer.observe(container, mutationObserverOptions)
5151
if (callback !== undefined) {
5252
onMutation()

0 commit comments

Comments
 (0)