unified

Project: mdx-js/mdx

Package: babel-plugin-html-attributes-to-jsx@1.6.6

  1. Dependencies: 4·Dependents: 0
  2. Coerce HTML attributes into something JSX and React friendly
  1. remark 182
  2. markdown 104
  3. mdx 16
  4. react 15
  5. jsx 11
  6. babel 4

babel-plugin-html-attributes-to-jsx

Coerce HTML attributes into something JSX and React friendly. Used by MDX.

Installation

yarn add babel-plugin-html-attributes-to-jsx

Usage

const babel = require('@babel/core')

const plugin = require('babel-plugin-html-attributes-to-jsx')

const jsx = `
export const Foo = () => (
  <div srcset="foo">
    <Button />
  </div>
)
`

const plugin = new BabelPluginHtmlAttributesToJsx()

const result = babel.transform(jsx, {
  configFile: false,
  plugins: ['@babel/plugin-syntax-jsx', plugin]
})

console.log(result.code)

Input

export const Foo = () => (
  <div srcset="foo">
    <Button />
  </div>
)

Output

const Foo = () => (
  <div srcSet="foo">
    <Button />
  </div>
)

License

MIT