Skip to content

Commit 190cd96

Browse files
authored
πŸ› (html-to-jsx) remove semicolon at start and keep empty prop values (#321)
* fixes #310 * πŸ› (html-to-jsx) remove semicolon at start and keep empty prop values Closes #279, closes #319
1 parent 462e872 commit 190cd96

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

β€Žcomponents/ConversionPanel.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,15 @@ const ConversionPanel: React.FunctionComponent<ConversionPanelProps> = function(
9595
splitEditorValue: splitTitle ? splitValue : undefined
9696
});
9797

98-
const prettyResult = await prettierWorker.send({
98+
let prettyResult = await prettierWorker.send({
9999
value: result,
100100
language: resultLanguage
101101
});
102+
103+
// Fix for #319
104+
if (prettyResult.startsWith(";<")) {
105+
prettyResult = prettyResult.slice(1);
106+
}
102107
setResult(prettyResult);
103108
setMessage("");
104109
} catch (e) {

β€Žpackage.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"build:analyze": "ANALYZE=true yarn build"
1616
},
1717
"engines": {
18-
"node": "12.x"
18+
"node": "14.x"
1919
},
2020
"dependencies": {
2121
"@babel/plugin-transform-flow-strip-types": "^7.16.0",

β€Žpatches/htmltojsx+0.3.0.patch

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/node_modules/htmltojsx/src/htmltojsx.js b/node_modules/htmltojsx/src/htmltojsx.js
2-
index afe4c85..b326beb 100644
2+
index afe4c85..960e450 100644
33
--- a/node_modules/htmltojsx/src/htmltojsx.js
44
+++ b/node_modules/htmltojsx/src/htmltojsx.js
55
@@ -326,19 +326,9 @@ HTMLtoJSX.prototype = {
@@ -44,3 +44,12 @@ index afe4c85..b326beb 100644
4444
return this.output;
4545
},
4646

47+
@@ -627,6 +618,8 @@ HTMLtoJSX.prototype = {
48+
result += '={' + attribute.value + '}';
49+
} else if (attribute.value.length > 0) {
50+
result += '="' + attribute.value.replace(/"/gm, '&quot;') + '"';
51+
+ } else {
52+
+ result += '=""';
53+
}
54+
return result;
55+
}

0 commit comments

Comments
Β (0)