Skip to content
This repository has been archived by the owner on Aug 24, 2019. It is now read-only.

Commit

Permalink
fix: handle special SVG attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Oct 5, 2018
1 parent b1c70ae commit efc529c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/h2x-plugin-jsx/src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,11 @@ describe('transformJsx', () => {
`<div id="foo" style={{"fontSize":10,"lineHeight":1.2}} />`,
)
})

it('should handle special SVG attributes', () => {
const code = `<svg autoReverse="false" externalResourcesRequired="true" focusable="true" preserveAlpha="false"></svg>`
expect(transform(code, { plugins: [transformJsx] }).trim()).toBe(
'<svg autoReverse="false" externalResourcesRequired="true" focusable="true" preserveAlpha="false" />',
)
})
})
3 changes: 2 additions & 1 deletion packages/h2x-plugin-jsx/src/visitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { isNumeric, hyphenToCamelCase } from './util'
const ATTRIBUTE_MAPPING = {
for: 'htmlFor',
class: 'className',
autoreverse: 'autoReverse',
externalresourcesrequired: 'externalResourcesRequired',
}

const ELEMENT_ATTRIBUTE_MAPPING = {
Expand Down Expand Up @@ -155,7 +157,6 @@ export default {
HTMLElement: {
enter(path) {
const jsxElement = new JSXElement()

jsxElement.name = transformTagName(path.node.tagName)
jsxElement.attributes = listToArray(path.node.attributes)
jsxElement.children = listToArray(path.node.childNodes)
Expand Down

0 comments on commit efc529c

Please sign in to comment.