-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Moves responsive image CSS back into attribute #19888
Moves responsive image CSS back into attribute #19888
Conversation
Fixes gatsbyjs#17593 This PR reverts a part of gatsbyjs#14816 that moved the image styles into a <style> tag in the head. Per this comment from @JoshuaWalsh, putting the styles in the <head> was just a cleanliness improvement, and did not affect the functionality that gatsbyjs#14816 was addressing: gatsbyjs#14816 (comment) Reverting this PR allows the responsive images to display correctly when the Remark HTML is displayed outside of the Gatsby layout, such as in an RSS feed.
Ah sounds like a good fix :) One semantic change is that before it was creating a css class that could apply to multiple elements. Afterwards this code is duplicated if multiple elements want to use it. I understand if this image is never intended to be re-used by multiple elements, it's just not clear in this PR. Can you confirm please? |
vertical-align: middle; | ||
position: absolute; | ||
top: 0; | ||
left: 0;`.replace(/\s*(\S+:)\s*/g, `$1`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this just .replace(/\s*/g, '')
? Or are we defensive about future updates where certain rules may be whitespace sensitive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Also, if you're stripping whitespace anyways, it's probably nice to have the closing backtick on the next line, aligned with the const
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review!
Not sure about the regexp. I copied it in from the older version of the file. I think being defensive here is a good move, though.
Since the regexp only strips before the CSS property name and between the colon and the value, it doesn’t strip the newline after the last line, so leaving backtick as-is.
Looks good to me. But tests are failing. You will have to re-run them with |
@pvdz I can’t say if anyone has started to put @vladar Thanks for the review! I updated the snapshots and pushed to this branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oki :)
Description
This PR reverts a part of #14816 that moved the image styles into a <style>
tag in the head. Per this comment from @JoshuaWalsh, putting the styles
in the was just a cleanliness improvement, and did not affect the
functionality that #14816 was addressing:
#14816 (comment)
Reverting this PR allows the responsive images to display correctly when
the Remark HTML is displayed outside of the Gatsby layout, such as in
an RSS feed.
Related Issues
Fixes #17593