babel-plugin-inline-react-svg icon indicating copy to clipboard operation
babel-plugin-inline-react-svg copied to clipboard

Adding aria-hidden attribute fails

Open reintroducing opened this issue 4 years ago • 4 comments

Hello, I'm trying to implement this plugin but it's failing on the following configuration:

{
    name: 'addAttributesToSVGElement',
    params: {
        attributes: [
            {
                fill: 'currentColor',
            },
            {
                'aria-hidden': true,
            },
        ],
    },
},

This produces a console error: Screen Shot 2021-05-04 at 8 26 38 AM

I also tried this configuration which produces the same thing:

{
    name: 'addAttributesToSVGElement',
    params: {
        attributes: [
            'fill="currentColor"',
            'aria-hidden="true"',
        ],
    },
},

I've taken a look at https://github.com/airbnb/babel-plugin-inline-react-svg/issues/33 and https://github.com/airbnb/babel-plugin-inline-react-svg/issues/42 which are both marked as fixed by https://github.com/airbnb/babel-plugin-inline-react-svg/pull/43 but I'm still seeing the issue present, although its no longer transforming to ariaLabel rather I believe the problem lies in the fact that its trying to use 'aria-label' as the attribute.

Is my configuration incorrect? Or is this an actual issue?

reintroducing avatar May 04 '21 15:05 reintroducing

What about ariaHidden?

ljharb avatar May 04 '21 15:05 ljharb

@ljharb that produces the following: Screen Shot 2021-05-04 at 8 41 23 AM

reintroducing avatar May 04 '21 15:05 reintroducing

What about:

        attributes: [
            {
                fill: 'currentColor',
                'aria-hidden': true,
            },
        ],

ljharb avatar May 04 '21 16:05 ljharb

@ljharb that produces the same error as the original screenshot.

reintroducing avatar May 04 '21 16:05 reintroducing