fix(gatsby-image): ensure that currentSrc exists#13287
Conversation
Trying to read `currentSrc` before it has been set throws an `Unable to get property 'length' of undefined or null reference` error. It should be an empty string, but IE11 can return `undefined`.
Instead of reading the `length`, we can just check to see if it's a value. This ensures it's not `undefined` and that it has a valid `src` URL
wardpeet
left a comment
There was a problem hiding this comment.
Thanks for fixing this regression! works like a charm!
|
I'm on ie11 and I don't get this issue as it's wrapped inside IOSupported which is never true on ie11. Nonetheless, it's an ok check |
|
Holy buckets, @thebuilder — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! |
The error i caught: https://sentry.io/share/issue/da7dc5b5859943e09889b2089f52ee3b/ There's a lot of moving parts, in |
* Ensure that currentSrc exists Trying to read `currentSrc` before it has been set throws an `Unable to get property 'length' of undefined or null reference` error. It should be an empty string, but IE11 can return `undefined`. * Check if the `currentSrc` has a value Instead of reading the `length`, we can just check to see if it's a value. This ensures it's not `undefined` and that it has a valid `src` URL
Trying to read
currentSrcbefore it has been set throws anUnable to get property 'length' of undefined or null referenceerror.It should be an empty string, but IE11 can return
undefined.The issue was introduced by #12468 - it's simply missing an extra guard to ensure the value is defined.