withastro/astro

Image class attribute is duplicated

Closed this issue · 0 comments

Astro Info

❯ astro info
Astro                    v5.0.2
Node                     v18.20.3
System                   Linux (x64)
Package Manager          unknown
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When using the astro:assets <Image> if you specify a class in the attributes the class is duplicated because:

https://github.com/withastro/astro/blame/24edead67a6a8a0e78f714ad53fb71792e0b9f1c/packages/astro/components/Image.astro#L60-L61

In that code the attributes.class is added to the end.

So if you <Image src="/image.png" class="my_class" alt="alt" />

The result is <img src="/image.png" alt="alt" class="my_class" class="my_class">


In the blitz reproduction is you run npm run build

it builds and then runs html-validate

/home/projects/llqiwjqjgj.github/dist/index.html
  2:241  error  Attribute "class" duplicated  no-dup-attr

✖ 1 problem (1 error, 0 warnings)

More information:
  https://html-validate.org/rules/no-dup-attr.html

What's the expected result?

The expected result is for the class to not be duplicated.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-asg5c8?file=dist%2Findex.html

Participation

  • I am willing to submit a pull request for this issue.