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

Conflict with format prop and SVG format attribute #1

Closed
joaogranado opened this issue May 26, 2016 · 2 comments
Closed

Conflict with format prop and SVG format attribute #1

joaogranado opened this issue May 26, 2016 · 2 comments

Comments

@joaogranado
Copy link

joaogranado commented May 26, 2016

With new support for SVG elements, added on react 15.0.0, format attribute is considered by the renderer a valid HTML attribute, resulting in the element being rendered with the content of the format prop, which in this case it is the raw output of the function being passed.

<div format="function format(value) {
  return format;
}">

I would suggest to remove format (and consequently every other unnecessary prop) from the props passed to React.createElement on render method. This could be easily accomplished on the destructuring assignment:

const { component, format, value, frameStyle, stepPrecision, ...rest } = this.props;

// ...

return React.createElement(
  component,
  { ...rest, style },
  format(adjustedValue)
);

Although this is a quick fix, I would suggest to rename format to something like formatValue, but it is up to you, since would lead to a breaking change. IMHO it would be a better solution in order to avoid conflicts with SVG's format attribute (considering the fact that this component supports SVG).

@joaogranado joaogranado changed the title Conflict with format prop and svg format attribute Conflict with format prop and SVG format attribute May 26, 2016
@nunorafaelrocha
Copy link

Agree with renaming to formatValue.

@ameyms
Copy link
Owner

ameyms commented Jun 6, 2016

I agree. I will rename it to formatValue. PRs also welcome.

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

3 participants