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

Commit efc529c

Browse files
committed
fix: handle special SVG attributes
gregberge/svgr#199
1 parent b1c70ae commit efc529c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/h2x-plugin-jsx/src/index.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,11 @@ describe('transformJsx', () => {
101101
`<div id="foo" style={{"fontSize":10,"lineHeight":1.2}} />`,
102102
)
103103
})
104+
105+
it('should handle special SVG attributes', () => {
106+
const code = `<svg autoReverse="false" externalResourcesRequired="true" focusable="true" preserveAlpha="false"></svg>`
107+
expect(transform(code, { plugins: [transformJsx] }).trim()).toBe(
108+
'<svg autoReverse="false" externalResourcesRequired="true" focusable="true" preserveAlpha="false" />',
109+
)
110+
})
104111
})

packages/h2x-plugin-jsx/src/visitor.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { isNumeric, hyphenToCamelCase } from './util'
77
const ATTRIBUTE_MAPPING = {
88
for: 'htmlFor',
99
class: 'className',
10+
autoreverse: 'autoReverse',
11+
externalresourcesrequired: 'externalResourcesRequired',
1012
}
1113

1214
const ELEMENT_ATTRIBUTE_MAPPING = {
@@ -155,7 +157,6 @@ export default {
155157
HTMLElement: {
156158
enter(path) {
157159
const jsxElement = new JSXElement()
158-
159160
jsxElement.name = transformTagName(path.node.tagName)
160161
jsxElement.attributes = listToArray(path.node.attributes)
161162
jsxElement.children = listToArray(path.node.childNodes)

0 commit comments

Comments
 (0)