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

Placeholder functionality breaks during Cyrpess tests and after prod build #580

Open
dsolanorush opened this issue Aug 2, 2022 · 5 comments
Labels
bug Something isn't working needs reproduction

Comments

@dsolanorush
Copy link

dsolanorush commented Aug 2, 2022

@pi0 @treboryx - I am seeing issues with this chunk of code during Cypress testing and after a production build:

img.onload = () => {
  this.$refs.img.src = this.nMainSrc;
  this.placeholderLoaded = true;
};

this.$refs.img is undefined when using the placeholder functionality, resulting in the error Cannot set properties of undefined (setting 'src')

The solutions that worked for me are:

  1. Simply don't use placeholder prop
  2. Add a check for existence of this.$refs.img in img.onload
@treboryx
Copy link
Contributor

treboryx commented Aug 2, 2022

Hi there! Thank you for your valuable feedback!

That is weird considering the ref should always be there as seen here:

<img :key="nSrc" v-bind="nAttrs" ref="img" :src="nSrc">

but I'll take a look!

EDIT: I'll probably need an example app where the issue is reproduceable since this looks concerning to me:
image

@dsolanorush
Copy link
Author

dsolanorush commented Aug 2, 2022 via email

@greetfish
Copy link

HI,how to do this 【Add a check for existence of this.$refs.img in img.onload】?

@Baroshem Baroshem added bug Something isn't working needs reproduction labels Dec 16, 2024
Copy link
Contributor

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a template for starting with a minimal reproduction:

👉 https://stackblitz.com/github/nuxt/image/tree/main/example

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

@greetfish
Copy link

greetfish commented Dec 16, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs reproduction
Projects
None yet
Development

No branches or pull requests

4 participants