metafizzy/fizzy-ui-utils

`getParent()` doesn't support searching a tree not in the `document.body`

jakewisse opened this issue · 0 comments

Encountered this issue when using Flickity in a React context, where the Flickity lazy loader's 'load' event listener was being processed after React had removed the DOM associated with the Flickity instance. The stack trace looks like this:

Uncaught TypeError: Cannot read property 'matches' of null
    at matchesSelector
    at Object.utils.getParent
    at Flickity.proto.getParentCell
    at LazyLoader.complete
    at LazyLoader.onload
    at LazyLoader.utils.handleEvent

Since the DOM that is being searched is no longer in the document, it reaches an element with no parentNode and throws this exception.