insin / babel-plugin-react-html-attrs

Babel plugin which transforms HTML and SVG attributes on JSX host elements into React-compatible attributes
https://astexplorer.net/#/gist/0008d677e8156dab437be51d1fee1757/latest
MIT License
177 stars 8 forks source link

Add MOAR attributes #5

Closed kostasmanionis closed 8 years ago

kostasmanionis commented 8 years ago

This should resolve https://github.com/insin/babel-plugin-react-html-attrs/issues/1 + transform SVG attributes.

I kinda figured it would be nice if this also transformed SVG attributes. We're using this for building react SVG components.

insin commented 8 years ago

Thanks for the PR, looks good.

kostasmanionis commented 8 years ago

I kinda lowballed on tests here, but I don't think there's much more to test here.

Few things I'd like to point out:

We're gonna be transforming all the event handler attributes <div onclick="doSomething();">Click me!</div> but it won't work since react only accepts functions.

And we're gonna be transforming svg attributes on non svg elements. Not sure if this is a problem though.

insin commented 8 years ago

On review, I'm not keen on having the event handlers in here, as that will never work in any HTML you're copying and pasting anyway.

I'm wondering if it would be cleaner to take the SVG props and spin them out into a new babel-plugin-react-svg-attrs.

kostasmanionis commented 8 years ago

So I've removed every onWhatever attribute from the list.

Also removed svg attributes. I'm cool with spinning of svg to a separate pacakge, we could also make a preset for people who want to use both.

insin commented 8 years ago

Nice, thanks.

Thinking the best option is probably to make this plugin configurable after dealing with #3.