Open kevinparkerson opened 4 years ago
I'll reopen this issue, since closing was done automatically, but no release has been published yet.
@pablosichert i stumbled upon this same issue when using this component on a Storyshot/Jest test. The stacktrace has a bunch of JSDOM on it, so maybe it's due to a difference between that and real browsers.
I'll probably pin my dependency to current master
to get the fix, but a patch release with that fix would be awesome too :)
Thanks for awesome library! it saved me quite some headaches fighting with -webkit-line-clamp
CSS property :grin:
I'll probably pin my dependency to current
master
to get the fix
Talked too soon. Couldn't pin the dependency to a github commit because it's not a release and so it does not include the lib/
directory and the main entry point fails :pensive:
I monkey-patching the Truncate library momentarily until a fix is released, to stop these error on the test suite. If it might help others, here's the terribly ugly code i used:
if (typeof jest !== 'undefined') {
const originalWillUnmount = Truncate.prototype.componentWillUnmount
Truncate.prototype.componentWillUnmount = function () {
if (!this.elements.ellipsis) {
this.elements.ellipsis = { parentNode: { removeChild() {} } }
}
originalWillUnmount?.call(this)
}
}
I am running into this as well. Any chance we can get a release that includes this fix? Many thanks for your work on this project :pray:
In
ComponentWillUnmount
,this.ellipsis
andthis.ellipsis.parentNode
need to be checked for before attempting removal so that it does not fail in test suites or other situations where it no longer exists. I will submit a PR for this simple fix shortly.