Skip to content

SVG attributes and ARIA attributes with different pattern #5617

@alansouzati

Description

@alansouzati

I have the following JSX sample, which is a SVG element:

    <svg className={className} viewBox="0 0 48 48" version="1.1"
      onClick={this.props.onClick} aria-label="Some random label">
      <g fill="none">
        <line strokeWidth="2" x1="24" y1="14" x2="24" y2="34"/>
        <line strokeWidth="2" x1="14" y1="24" x2="34" y2="24"/>
      </g>
    </svg>

In raw HTML strokeWidth is represented as stroke-width. It seems to me that all JSX attributes follow the camel-case format. So, I immediately thought on adding ariaLabel instead of aria-label.

Question: Is there a pattern for JSX attributes? If yes, why aria-* does not follow this pattern?

In fact, I like the idea of having stroke-* so that I don't have to preprocess my raw svg to reactjs.

I understand that this could be the expected behavior, but I'm just trying to understand why the patterns are different for aria and svg.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions