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

Unable to override the role attribute. #14791

Closed
1 of 4 tasks
justin-schroeder opened this issue Mar 22, 2019 · 9 comments
Closed
1 of 4 tasks

Unable to override the role attribute. #14791

justin-schroeder opened this issue Mar 22, 2019 · 9 comments
Assignees
Milestone

Comments

@justin-schroeder
Copy link

justin-schroeder commented Mar 22, 2019

Describe the problem

When using the Font Awesome SVG with JS it is not possible to override the role attribute. Given the following:

<i class="fa fa-arrow-right" role="presentation" data-custom-attr="true"></i>

Font Awesome converts this into:

<svg class="svg-inline--fa fa-arrow-right fa-w-14" aria-hidden="true" data-prefix="fa" data-icon="arrow-right" role="img" data-custom-attr="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg="">
    <path fill="currentColor" d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"></path>
</svg>

Specifically the issue is role="img" was not overridden even though role="presentation" was defined on the icon.

What did you expect?

role="img" to be replaced with role="presentation".

<svg class="svg-inline--fa fa-arrow-right fa-w-14" aria-hidden="true" data-prefix="fa" data-icon="arrow-right" role="presentation" data-custom-attr="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg="">
    <path fill="currentColor" d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"></path>
</svg>

Ideally, <i> tag attributes would take precedent over attributes being injected on the svg. Most of them do, but to my knowledge at least the role attribute does not transfer.

What version and implementation are you using?

Version: 5.3.1
Browser and version: Chrome, safari, firefox

  • SVG with JS
  • Web Fonts with CSS
  • SVG Sprites
  • On the Desktop

Reproducible test case

https://codepen.io/justin-schroeder/pen/NJeMGV

Pretty simple test case, you'll see role="presentation" is not being overridden, and I've broken out all the existing attributes on the element for easy viewing.

@robmadole
Copy link
Member

Thanks @justin-schroeder ! We'll get it rolling.

@robmadole robmadole self-assigned this Mar 22, 2019
@justin-schroeder
Copy link
Author

justin-schroeder commented Mar 27, 2019

We'll get it rolling.

😄 no pun intended i'm sure.

@robmadole
Copy link
Member

That was intended! But you caught it 👏. My kids would say the appropriate response is 🙄

This was referenced May 7, 2019
@arnorhs
Copy link

arnorhs commented Jan 29, 2021

Any word on this issue?

It seems to still be behaving the same way. Also affecting the react version.

@tagliala
Copy link
Member

This should have been fixed in version 5.8.2

I can see it is fixed by changing the Font Awesome version in the reproducible test case (https://codepen.io/justin-schroeder/pen/NJeMGV)

Could you please provide a reproducible test case?

(labeling and closing here, but feel free to comment, I will reopen if it is the case)

@tagliala tagliala added this to the 5.8.2 milestone Jan 29, 2021
@joewhitsitt
Copy link

From the example in #14791 (comment)
Screen Shot 2021-01-29 at 8 26 23 AM

Isn't it supposed to be presentation instead of img?

@joewhitsitt
Copy link

Sorry. I jumped to conclusions. The pen was set to 5.8.0. Changed it to 5.8.2 and I got this:

Screen Shot 2021-01-29 at 8 29 27 AM

Thank you for this!

@justin-schroeder
Copy link
Author

@joewhitsitt I just updated my codepen to 5.8.2 and saved it so the next person can see its been fixed too 👍

@tagliala
Copy link
Member

Good, thanks for the feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants