0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/.changeset/wicked-laws-heal.md
Emmanuel Chucks ed2dfdae5b
fix: updates <Picture /> to pass HTML attributes down to the <img /> element (#5038)
* fix: also pass attrs to underlying img

`class` for direct img styling, `width` & `height` to prevent layout shift, etc need to be passed to the underlying img tag to work.

* remove redundant attr from picture tag

* revert to previous commit

- seemed to break some tests
- can't deal with fixing that right now, maybe later

* only passing attributes to the img

* adding a note to the README

* chore: add changeset

Co-authored-by: Tony Sullivan <tony.f.sullivan@outlook.com>
2022-10-20 19:42:36 +00:00

11 lines
485 B
Markdown

---
'@astrojs/image': minor
---
HTML attributes included on the `<Picture />` component are now passed down to the underlying `<img />` element.
**Why?**
- when styling a `<picture>` the `class` and `style` attributes belong on the `<img>` itself
- `<picture>` elements [should not](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture#attributes) actually provide any `aria-` attributes
- `width` and `height` can be added to the `<img>` to help prevent layout shift