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

Commit 1b25c34

Browse files
authored
Merge pull request #15 from smooth-code/fix-various-bugs
Various fixes
2 parents c923005 + e8d5009 commit 1b25c34

File tree

7 files changed

+1734
-1437
lines changed

7 files changed

+1734
-1437
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
language: node_js
22

33
node_js:
4-
- 6
54
- 8
65
- 10
76

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212
"test": "jest --runInBand"
1313
},
1414
"devDependencies": {
15-
"@babel/cli": "^7.0.0",
16-
"@babel/core": "^7.0.1",
17-
"@babel/plugin-proposal-class-properties": "^7.0.0",
18-
"@babel/preset-env": "^7.0.0",
15+
"@babel/cli": "^7.1.2",
16+
"@babel/core": "^7.1.2",
17+
"@babel/plugin-proposal-class-properties": "^7.1.0",
18+
"@babel/preset-env": "^7.1.0",
1919
"babel-core": "7.0.0-bridge.0",
20-
"babel-eslint": "^9.0.0",
20+
"babel-eslint": "^10.0.1",
2121
"babel-jest": "^23.6.0",
2222
"codecov": "^3.1.0",
23-
"eslint": "^5.6.0",
23+
"eslint": "^5.6.1",
2424
"eslint-config-airbnb-base": "^13.1.0",
25-
"eslint-config-prettier": "^3.0.1",
25+
"eslint-config-prettier": "^3.1.0",
2626
"eslint-plugin-import": "^2.14.0",
2727
"jest": "^23.6.0",
28-
"lerna": "^3.4.0",
29-
"prettier": "^1.14.2"
28+
"lerna": "^3.4.1",
29+
"prettier": "^1.14.3"
3030
},
3131
"workspaces": [
3232
"packages/*"

packages/h2x-parse/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
},
1515
"dependencies": {
1616
"h2x-types": "^1.1.0",
17-
"jsdom": "^12.0.0"
17+
"jsdom": ">=11.0.0"
1818
}
1919
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ const formatElementOpen = jsxElement => {
2020
const formatElementClose = jsxElement => `</${jsxElement.name}>`
2121

2222
const formatComment = jsxComment =>
23-
`{/*${jsxComment.text.replace('*/', '* /')}*/}`
23+
`{/*${jsxComment.text.replace(/\*\//g, '* /')}*/}`
2424

25-
const formatText = jsxText => jsxText.text
25+
const formatText = jsxText => jsxText.text.replace(/`/g, '\\`')
2626

2727
export default {
2828
JSXElement: {
@@ -44,7 +44,7 @@ export default {
4444
JSXText: {
4545
enter(path, generator) {
4646
const trimmedText = path.node.text.trim()
47-
if (trimmedText) generator.writeLine(formatText(path.node))
47+
if (trimmedText) generator.writeLine(`{\`${formatText(path.node)}\`}`)
4848
},
4949
},
5050
}

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ describe('transformJsx', () => {
77
<?xml version="1.0" encoding="UTF-8"?>
88
<svg width="88px" height="88px" viewBox="0 0 88 88" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
99
<!-- Generator: Sketch 46.2 (44496) - http://www.bohemiancoding.com/sketch -->
10+
<style>
11+
.test {
12+
fill: red;
13+
}
14+
</style>
1015
<title>Dismiss</title>
1116
<desc>Created with Sketch.</desc>
1217
<defs>
@@ -57,11 +62,16 @@ describe('transformJsx', () => {
5762
.toBe(`{/*?xml version="1.0" encoding="UTF-8"?*/}
5863
<svg width="88px" height="88px" viewBox="0 0 88 88" version={1.1} xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink">
5964
{/*Generator: Sketch 46.2 (44496) - http://www.bohemiancoding.com/sketch*/}
65+
<style>
66+
{\`.test {
67+
fill: red;
68+
}\`}
69+
</style>
6070
<title>
61-
Dismiss
71+
{\`Dismiss\`}
6272
</title>
6373
<desc>
64-
Created with Sketch.
74+
{\`Created with Sketch.\`}
6575
</desc>
6676
<defs>
6777
<linearGradient id="a" x1="50%" x2="50%" y1="0%" y2="100%">
@@ -91,4 +101,11 @@ describe('transformJsx', () => {
91101
`<div id="foo" style={{"fontSize":10,"lineHeight":1.2}} />`,
92102
)
93103
})
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+
})
94111
})

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)