Skip to content

Commit

Permalink
fix: Reference Node and MutationObserver off of the window object rat…
Browse files Browse the repository at this point in the history
…her than globally (#77)

You have to handle shims yourself if not using jest without this
  • Loading branch information
dadamssg authored and Kent C. Dodds committed Jul 19, 2018
1 parent 6e9d7c5 commit 7730d25
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/get-node-text.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
function getNodeText(node) {
return Array.from(node.childNodes)
.filter(
child => child.nodeType === Node.TEXT_NODE && Boolean(child.textContent),
child =>
child.nodeType === window.Node.TEXT_NODE && Boolean(child.textContent),
)
.map(c => c.textContent)
.join(' ')
Expand Down
2 changes: 1 addition & 1 deletion src/wait-for-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function waitForElement(
onDone(lastError || new Error('Timed out in waitForElement.'), null)
}
timer = setTimeout(onTimeout, timeout)
observer = new MutationObserver(onMutation)
observer = new window.MutationObserver(onMutation)
observer.observe(container, mutationObserverOptions)
if (callback !== undefined) {
onMutation()
Expand Down

0 comments on commit 7730d25

Please sign in to comment.