Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting Image fails with uncaught when NuxtImg is no longer in DOM #783

Closed
chrisspiegl opened this issue Mar 28, 2023 · 0 comments
Closed

Comments

@chrisspiegl
Copy link
Contributor

I was building a filter mechanism for videos with their respective thumbnails.

When the user switches the filters quickly, it can happen that images start loading but then with the next filter trigger, the images no longer appear.

However, in the Background, NuxtImg is still trying to load the image file and then replace the img.src.

This fails with the following error since the img tag is no longer in the dom.

Uncaught TypeError: Cannot set properties of null (setting 'src')
    at img.onload (nuxt-img.mjs?v=028fb104:82:1)

I think a quick fix would be to check inside the on('load',… if the img tag is still present and then only replace if it is.

I could do a Pull request on this if it's something you're open to.

Thanks 🌸
Chris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant